Reputation: 13588
I have a label, which has been created using iOS Storyboard layout.
Contents of label, however, are dynamic and can change during run time.
How do I make sure that label's height gets adjusted based on the content in the label.
I tried:
Setting number of lines to 0
Setting Editor -> Size to Fit Content
.
But they don't work. Text in label gets printed only in single line, and as a result of that some of text doesn't appear on the screen.
Any help would be highly appreciated.
Upvotes: 10
Views: 8858
Reputation: 3888
Your lable should be number of lines to 0
give height constraint to lable and select height constraint then set greater than equal , it will automatically adjust height based on content
Upvotes: 11
Reputation: 330
Please check your constraints. You can't set label's height constraint.If superview's height is fixed,you can't set top and bottom constraint at same time.Because it means you set the height constraint of label. So you can must fix label width and you can't fix label height.
Upvotes: 1