设置label约束的优先级

//横向设置label的优先级
//1. 抗拉伸(优先级越高,越不容易被拉伸)
[label_1 setContentHuggingPriority:UILayoutPriorityDefaultLow
                                          forAxis:UILayoutConstraintAxisHorizontal];
[label_2 setContentHuggingPriority:UILayoutPriorityRequired
                                          forAxis:UILayoutConstraintAxisHorizontal];
//2. 抗压缩(优先级越高,越不容易被压缩)
[label_1 setContentCompressionResistancePriority:UILayoutPriorityDefaultLow
                                                        forAxis:UILayoutConstraintAxisHorizontal];
[label_2 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                        forAxis:UILayoutConstraintAxisHorizontal];

推荐阅读更多精彩内容