Prajoth
Prajoth

Reputation: 900

How to Align Label Text to the Top

I have a label in a UIScrollView that gets its string contents from a website. I was wondering how to make the label display the text so that it is not centered, but is top aligned. The text in the label keeps displaying in the center of the label, which looks awkward in a scroll view. I want the label to display the text starting from the top. Thanks!

Upvotes: 1

Views: 4132

Answers (2)

vicente.erick
vicente.erick

Reputation: 17

If you use auto layout, you need to adjust your constraint of height to "Less than or equals" and update your constant to the maximum you need.

Upvotes: 2

Filip Radelic
Filip Radelic

Reputation: 26683

Call -sizeToFit on this label after setting it's text. If all you have in this scrollview is a label, you could also adjust it's contentSize after that.

Upvotes: 3

Related Questions