今天在Masonry:使用純代碼進行iOS應(yīng)用的autolayout自適應(yīng)布局看到了這樣一個小技巧,發(fā)現(xiàn)之前寫的一段段的代碼,完全可以這樣寫了。不用那么費勁了憔四。。
@property (nonatomic, strong) MASConstraint *topConstraint;
...
// when making constraints
[view1 mas_makeConstraints:^(MASConstraintMaker *make) {
self.topConstraint = make.top.equalTo(superview.mas_top).with.offset(padding.top);
make.left.equalTo(superview.mas_left).with.offset(padding.left);
}];
...
// 然后你就可以操作這個屬性.
[self.topConstraint uninstall];