Is it possible to vertically align text inside labels with a “large” frame

前端 未结 8 1605
梦谈多话
梦谈多话 2021-01-01 11:58

In my application I have multiple tableviews with custom cells. Some of the text in the cells are spread out on between 2-4 lines so the height of the label is large enough

8条回答
  •  离开以前
    2021-01-01 12:34

    Its impossible to align the text in UILabel vertically. But, you can dynamically change the height of the label using sizeWithFont: method of NSString, and just set its x and y as you want.

    As an alternative you can use UITextField. It supports the contentVerticalAlignment peoperty as it is a subclass of UIControl. You have to set its userInteractionEnabled to NO to prevent user from typing text on it.

提交回复
热议问题