查看约束优先级的方法

1     for (UIView* subview in self.underView.subviews) {
2         for ( NSLayoutConstraint *constraint in subview.constraints) {
3             NSLog(@"constraint:%@====>%f",constraint,constraint.priority);
4         }
5     }

1>由于在 Xcode autolayout 布局时,在 IB 中查看约束的优先级很费劲,可以通过以上代码打印出来,快速找到高优先级或低优先级的约束.

2>另外,在 IB 中,约束的优先级如果不是1000,约束的长方形框会变成虚线.

posted on   活最好的自己  阅读(230)  评论(0编辑  收藏  举报

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示