Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can UILabel constraint have both min and max height?

I would like my label to be at least a certain height and a maximum of another height. How do I achieve this with constraints?

like image 780
Aaron Bratcher Avatar asked Oct 24 '25 02:10

Aaron Bratcher


1 Answers

You can achieve this by creating two height constraints and change their relations to Greater Than or Equal for the minimum height and Less Than or Equal for the maximum height.

In Interface Builder you can change the Relation in the Size Inspector of the Constraint.

Change Relation in Xcode

To add a second height constraint is as easy as adding any other constraint. Add the second one as you do with the first.

Example:

Adding constraints in Xcode

After that you just have to follow the way I described above.

like image 151
Tobias Avatar answered Oct 26 '25 16:10

Tobias