如何使用 NSLayoutConstraints 固定两个以上宽度相等的 UIView?
现在,我正在使用以下代码,并且不能固定两个以上的 UIView:
for (int i = 0; i < column.count; i++) {
NSString *horizontalFormat = @"H:|[view1][view2(==view1)]|";
NSDictionary *views;
if (i < column.count - 1) {
views = @{
@"view1": column[i],
@"view2": column[i + 1]
};
}else{
views = @{
@"view1": column[i - 1],
@"view2": column[i]
};
}
NSArray * horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:horizontalFormat
options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom
metrics:nil
views:views];
[self.contentView addConstraints:horizontalConstraints];
}
有任何想法吗?