masonry 使用过程中的解惑
2018-03-21 本文已影响15人
petter102
在masonry的readme 文档里发现如下一段解释
NSArray
An array of a mixture of any of the previous types
make.height.equalTo(@[view1.mas_height, view2.mas_height]);
make.height.equalTo(@[view1, view2]);
make.left.equalTo(@[view1, @100, view3.right]);
让我很是不理解 make是被约束对象
解释过来应该是
myview的高等于这个数组
Google了一下 发现遇到这个问题的不止我一个 在issue列表里发现了原作者的解释
Say you have 3 views and you want all their heights to be equal you could write this as
[view3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.equalTo(view1.mas_height);
make.height.equalTo(view2.mas_height);
}];
Alternatively you could pass an array and it would result in the exact same constraints
make.height.equalTo(@[view1.mas_height, view2.mas_height]);
就是说 你想让三个view的高相等的时候可以这么写。