- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_masonryViewArray = [NSMutableArray array];
for (int i = ; i<; i++) {
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor redColor];
view.frame = CGRectMake(, , , );
[self.view addSubview:view];
[_masonryViewArray addObject:view];
}
[self test_masonry_vertical_fixItemWidth];
[self.view updateConstraintsIfNeeded];
} - (void)test_masonry_horizontal_fixSpace{
//实现masonry水平固定间隔方法
[self.masonryViewArray mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing: leadSpacing: tailSpacing:];
//设置array的垂直方向的约束
[self.masonryViewArray mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo();
make.height.equalTo();
}];
} - (void)test_masonry_horizontal_fixItemWidth{
//实现masonry水平固定空间宽度方法
[self.masonryViewArray mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength: leadSpacing: tailSpacing:];
//设置array的垂直方向的约束
[self.masonryViewArray mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo();
make.height.equalTo();
}];
} - (void)test_masonry_vertical_fixSpace{
//实现masonry垂直固定控件高度方法
[self.masonryViewArray mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedSpacing: leadSpacing: tailSpacing:];
//设置array的水平方向的约束
[self.masonryViewArray mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo();
make.width.equalTo();
}];
} - (void)test_masonry_vertical_fixItemWidth{
//实现masonry垂直固定控件高度方法
[self.masonryViewArray mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedItemLength: leadSpacing: tailSpacing:];
//设置array的水平方向的约束
[self.masonryViewArray mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo();
make.width.equalTo();
}];
}

Masonry 等间隔或等宽高排列多个控件的更多相关文章

  1. android屏幕适配的全攻略3-动态获取手机屏幕宽高及动态设置控件宽高

    1.获取手机屏幕宽高: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetr ...

  2. 高仿QQ顶部控件之IOS SegmentView

    经常会看到QQ上面有一个 消息和电话 的顶部面板,这个空间是IOS7的分段控制,android中没有这个控件,今天在威哥的微信公众号中成功gank到这个自定义控件的实现,下面跟着尝试一波. 首先是定义 ...

  3. Flutter 宽高比(比率)控件 AspectRatio

    const AspectRatio({ Key key, @required this.aspectRatio, Widget child,}) void main() {  runApp(    n ...

  4. 【Flutter学习】页面布局之宽高尺寸处理

    一,概述 Flutter中拥有30多种预定义的布局widget,常用的有Container.Padding.Center.Flex.Row.Colum.ListView.GridView.按照< ...

  5. iOS Masonry控件等比例布局

    一.先解释相关API 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 /**  *  distribute with fixed spacing  *  *  ...

  6. ElegantSnap 一个优雅的,易用的iOS/tvOS/macOS自动布局框架, 超级详细的使用教程,多视图水平等宽/垂直等高排列

    ElegantSnap ElegantSnap(Base on SnapKit) to make Auto Layout easy and elegant on both iOS and OS X. ...

  7. 【Android 应用开发】 自定义组件 宽高适配方法, 手势监听器操作组件, 回调接口维护策略, 绘制方法分析 -- 基于 WheelView 组件分析自定义组件

    博客地址 : http://blog.csdn.net/shulianghan/article/details/41520569 代码下载 : -- GitHub : https://github.c ...

  8. 多媒体开发之h264中的sps---sps信息提取之分辨率宽高提取2

    -------------------author:pkf -----------------------------time:2015-8-20 -------------------------- ...

  9. H5 canvas的 width、height 与style中宽高的区别

    Canvas 的width height属性 1.当使用width height属性时,显示正常不会被拉伸:如下 <canvas id="mycanvas" width=&q ...

随机推荐

  1. 12、geo数据上传

    1.注册一个NCBI账户 注册geo账户(老用户和新用户): https://www.ncbi.nlm.nih.gov/geo/submitter/ 有3个月的时间 GEO DataSets > ...

  2. (转载)Windows无法安装到GPT分区形式磁盘解决办法

    之前使用的是windows7 + ubuntu18.04双系统,硬盘分区采用的是GPT格式.重装windows系统时,提示“windows无法安装到这个磁盘.选中的磁盘采用GPT分区形式”,导致安装失 ...

  3. tensorflow第一个例子

    import tensorflow as tf import numpy as np # create data x_data = np.random.rand(100).astype(np.floa ...

  4. 17. CTF综合靶机渗透(十)

    靶机描述:欢迎来到超级马里奥主机!这个虚拟机是对真实世界场景场景的模拟.目标是在VM中找到2个标志.根是不够的(对不起!)VM可以以多种方式开发,但请记住枚举是关键.挑战的程度是中等的.感谢VDBAN ...

  5. MVC下使用ajax后台查询值赋值到前端控件

    初学MVC,今天做个简单的功能,就是输入BeginDate和EndDate,从后台计算后赋值给另外一个文本框Amount 界面很简单,方法也很简单,今天就使用jquery的post方法,先准备后台代码 ...

  6. 剑指Spring源码(三)俯瞰Spring的Bean的生命周期(大众版)

    距离上一次写Spring源码解析,已经过去了快要好几个月了,主要原因还是Spring的源码解析类文章太难写了,不像我先前写的什么CAS源码,AQS源码,LinkedBlockingQueue等等,这些 ...

  7. Scrapy 框架进阶笔记

    上一篇简单了解了scrapy各个模块的功能:Scrapy框架初探 -- Dapianzi卡夫卡 在这篇通过一些实例来深入理解 scrapy 的各个对象以及它们是怎么相互协作的 settings.py ...

  8. 【转】C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字

    源地址:http://www.cnblogs.com/94cool/p/4332957.html

  9. ssh-ssh整合(Struts2+Sprinig+hibernate)

    在之前呢我们已经讲解过ssm以及ssm2的整合开发,今天我们进行ssh的整合,在之前已经有一篇整合ssh的文章,那是基于注解开发的,今天讲解的为基于配置文件注入方式进行开发.思路:spring管理hi ...

  10. Linux 调优方案, 修改最大连接数(ulimit命令)

    https://blog.csdn.net/isoleo/article/details/51732687 https://www.cnblogs.com/zengkefu/p/5649407.htm ...