How to change UILabel height dynamically to fit all text

In two steps we can make a UILabel change its height dynamically without writing code.

UILabel dynamic height

First select your UILabel and from “Identity inspector” set number of lines property to 0.

UILabel dynamic height

Next add Top, Trailing, Leading and Height constraints then select the height constraint and change its “Relation” property from “Equal” to “Greater Than or Equal”

Xcode UILabel dynamic height

That’s it, try changing the text programmatically and watch the results.

iOS UILabel dynamic height

You might like How to change UITextField placeholder color from interface

Leave a Reply

Your email address will not be published. Required fields are marked *