iOS Masonry 设置布局优先级。
Masonry 中设置布局优先级需要使用系统方法:
设置抗拉伸性。值越低越容易被拉伸
- (void)setContentHuggingPriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis;
实例代码:
[A setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[B setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
由于B的抗拉伸值低,故需要拉伸时,优先拉伸B
设置抗压缩性。 值越低,越容易被压缩
- (void)setContentCompressionResistancePriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis
实例代码
[A setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[B setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
由于B的抗压缩值低。故需要压缩时,优先压缩B