UITextView that expands to text using auto layout

前端 未结 16 2105
面向向阳花
面向向阳花 2020-11-28 01:25

I have a view that is laid out completely using auto layout programmatically. I have a UITextView in the middle of the view with items above and below it. Everything works f

16条回答
  •  一个人的身影
    2020-11-28 01:42

    You can also do it without subclassing UITextView. Have a look at my answer to How do I size a UITextView to its content on iOS 7?

    Use the value of this expression:

    [textView sizeThatFits:CGSizeMake(textView.frame.size.width, CGFLOAT_MAX)].height
    

    to update the constant of the textView's height UILayoutConstraint.

提交回复
热议问题