UIView with dynamic height multiple UILabel

后端 未结 2 1938
遇见更好的自我
遇见更好的自我 2020-12-28 20:51

I\'m making a custom UIView with 2 UILabel in it, with each UILabel having dynamic height. I\'m unable to set constraints for dynamic height. (I\'m new to Auto-Layout &

2条回答
  •  孤城傲影
    2020-12-28 20:57

    1. Set the Lines property of both labels to 0 in interface builder.
    2. Make sure there is no constraint for height of any of the labels or the uiview.
    3. Make sure there are no constraints on uiview which force it to a certain size, for example, if you have a constraint on uiview for certain distance from top of superview and another constraint of certain distance from bottom of superview, it will not work.
    4. Try changing the text of labels in code and height should automatically adjust.

提交回复
热议问题