- 约束优先级:在Autolayout中每个约束都有一个优先级,优先级的范围是1 ~ 1000;创建一个约束,默认的优先级是1000,是最高的级别
- Content hugging priority:该优先级表示一个控件抗被拉伸的优先权;优先级越高,越不容易被拉伸,默认是250
- **Content Compression Resistance Priority:该优先级表示一个控件抗被压缩的优先级。优先级越高,越不容易被压缩,默认是750
- (UILayoutPriority)contentHuggingPriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
- (void)setContentHuggingPriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
- (UILayoutPriority)contentCompressionResistancePriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
- (void)setContentCompressionResistancePriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
在控件的初始化中进行设置
[leftLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
[rightLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
网友评论