for (NSInteger i = 0; i < self.scrollViews.count; i++) {
UIScrollView * currentS = self.scrollViews[i];
UIScrollView * previousS = i > 0 ? self.scrollViews[i-1] : nil;
[currentS mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.width.height.equalTo(self.scrollView);
if (previousS) {
make.left.equalTo(previousS.mas_right);
} else {
make.left.equalTo(self.scrollView);
}
}];
}
// 另外一种判断
for (NSInteger i = 0; i < self.scrollViews.count; i++) {
UIScrollView * currentS = self.scrollViews[i];
[currentS mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.width.height.equalTo(self.scrollView);
if (i == 0) {
make.left.equalTo(self.scrollView);
} else {
make.left.equalTo(self.scrollViews[i-1].mas_right);
}
}];
}
网友评论