有这样一个场景,在tableviw中的cell显示文字,左边是标题,右边是内容,但是左右两边的字数都是不确定的,为了能够很好的显示,通常会对两个label进行约束,标题向左约束5px,中间对齐。内容向右约束5px,中间对齐,标题与内容的间隔为5px。

假如优先级没有设置好,那么会是这样的效果,红色的箭头的title被挤出去了,原因是右边的label的优先级
(Content Hugging priorty和Content Compression resistance Priority)比左边高。



调整之后效果如下

网友评论