Reputation: 2180
I expected from the label to keep the minimal height of one line even if you remove the text out of it.
Here's the picture:
How it should look (but without whitespace):
If I enter the one whitespace in it, its height gets corrected. But I dont want to put whitespace into empty labels. there should be a better solution.
Upvotes: 7
Views: 4226
Reputation: 1080
One workaround is to use a UITextField
instead, set isEnabled
to false
, and set the placeholder
property to " "
.
As long as you don't need it's width to ever be shorter than the width of a single space -- UITextFields'
sizes are calculated using the placeholder
property by default -- then this will always have the height of a non-empty UITextField
regardless of whether it contains text or not.
Upvotes: 2
Reputation: 6648
First, add a Width and a Height constraints:
Second, change the Equal
to the Bigger Than
(both for width and height, height could be small one, like 8):
Finally, you are able to change the font size of label freely, the label will became bigger with the bigger font size. And the label size will be (42,8) if you removed text:
Upvotes: 6
Reputation: 20804
The UILabel
control have an intrinsic content size so if you don't have any text his height
will be zero, If you need a min height
then you must define a Height constraint with >= your minValue
as I said in my comments
I think you can figured it out how do this
Upvotes: 6