Vertically align text within a UILabel (Note : Using AutoLayout)

前端 未结 17 2700
忘掉有多难
忘掉有多难 2020-12-23 02:24

I am Copying the same Question asked Before Question. I have tried the solutions given and was not able to solve it since sizetofit was not effective when I

17条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 02:39

    There is an easy solution for cases where the height of a label doesn't need to be constant: put your Label in a Stack View. Be sure to add leading and trailing constants to the Stack View. Here is a screenshot of how to do it in storyboard:

提交回复
热议问题