how to make UITextView height dynamic according to text length?

前端 未结 21 2324
隐瞒了意图╮
隐瞒了意图╮ 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 05:50

    this Works for me, all other solutions didn't.

    func adjustUITextViewHeight(arg : UITextView)
    {
        arg.translatesAutoresizingMaskIntoConstraints = true
        arg.sizeToFit()
        arg.scrollEnabled = false
    }
    

    In Swift 4 the syntax of arg.scrollEnabled = false has changed to arg.isScrollEnabled = false.

提交回复
热议问题