Vertically align UILabel

前端 未结 10 1607
故里飘歌
故里飘歌 2020-12-31 10:34

I am trying to vertically align the text in the UILabel view of my app. The problem is that I want the text to be vertically aligned to the top and the size of the label to

10条回答
  •  无人及你
    2020-12-31 10:47

    There's a way without subclassing, using a button or rolling your own.

    set the number of lines to 0, then call sizeToFit.

    [label setNumberOfLines:0];
    [label sizeToFit];
    

    More details here as i think someone else linked to: Vertically align text to top within a UILabel

提交回复
热议问题