how to make UITextView height dynamic according to text length?

前端 未结 21 2341
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 05:44

As you can see in this image

the UITextView changes it\'s height according to the text length, I want to make it adjust it\'s height according to the te

21条回答
  •  长情又很酷
    2020-11-28 06:14

    Tested on Xcode 11.2.1, Swift 5.1:

    All I had to do was:

    1. Set the constraints to the top, left, and right of the textView.
    2. Disable scrolling in Storyboard.

    Doing so allowed autolayout to kick in and dynamically size the textView based on its content.

提交回复
热议问题