To update UITextView height with it's content height, you need to update the correspond height constraint. Otherwise, it won't work.

extension UITextView {
    func heightThatFitsContent() -> CGFloat {
        let fixedWidth = self.frame.width
        let newSize = self.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat(MAXFLOAT)))

        return newSize.height
    }
}

textViewHeightConstraint.constant = textview.heightThatFitsContent()

results matching ""

    No results matching ""