Masonry 布局举例:类似UIStackView类型布局
2018-01-09 本文已影响161人
Eddiegooo
Masonry 布局
多个同样的View 放在一起,根据数据多少来进行布局,很方便啊。。。
//这里加了一组长的一样的View。
[self.view addSubview:customView];
//将View添加到数组中
[self.viewArray addObject:customView];
/*!
* self.viewArray: 数组容器
* HelperMASAxisTypeVertical: 排列方向
* FixedSpacing: 间距
* 左右间距。。。
*/
[self.viewArray mas_distributeViewsAlongAxis:HelperMASAxisTypeVertical withFixedSpacing:10 leadSpacing:0 tailSpacing:0];
//整体的位置
[self.viewArray mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.view);
}];