如何在Interface Builder中限制UIView的高度

时间:2015-06-30 15:39:19

标签: ios swift interface-builder

我有一个UIView,其高度为40.但我内部有一个UILabel,可以是一行或多行。如何根据具体情况调整UIView?如果我需要,我愿意在Swift中这样做但是如果在Interface Builder中有一种方法会更好。

1 个答案:

答案 0 :(得分:2)

  1. 通过IB为您的标签添加顶部,左侧,右侧,底部约束,并将行数设置为0
  2. enter image description here

    1. 为容器视图添加灵活高度(添加高度约束并将其更改为大于或等于) enter image description here

    2. 现在,如果您设置长测试 - 它将自动扩展容器视图:

    3. enter image description here