Masonry小技巧门
来自 https://github.com/SnapKit/Masonry/issues/119
1 .属性中添加 约束
//
@property MASConstraint * expressWayViewHeight0;
@property MASConstraint * carWayViewViewHeight0;
//
- 开启约束,并存储约束
[_expressWayView mas_updateConstraints:^(MASConstraintMaker *make) {
_expressWayViewHeight0 = make.height.mas_equalTo(0).priority(1000);
}];
[_carWayView mas_updateConstraints:^(MASConstraintMaker *make) {
_carWayViewViewHeight0 = make.height.mas_equalTo(0).priority(1000);
}];
3 在需要的地方 移除(卸载)或者安装
if ([text.text isEqualToString:@"新增快递"] ||[text.text isEqualToString:@"原路返回"]) {
[_carWayViewViewHeight0 uninstall];
[_expressWayViewHeight0 install];
}else if ([text.text isEqualToString:@"自行派送"] ||[text.text isEqualToString:@"专车配送"]) {
[_carWayViewViewHeight0 install];
[_expressWayViewHeight0 uninstall];
}
}
另外
mas_updateConstraints 也会产生 约束的数组
[MASViewConstraint installedConstraintsForView:yourView] 可以拿到所有约束数组