该例演示一组视图的约束的整体更新。核心代码如下:
- (void)updateConstraints {
[self.buttonViews updateConstraints:^(MASConstraintMaker *make) {
make.baseline.equalTo(self.mas_centerY).with.offset(self.offset);
}];
//according to apple super should be called at end of method
[super updateConstraints];
}
对于相同UI行为的一组视图,通过视图数组整体更新其约束,非常方便。