I am working on a chat app. The message box resizes according to the length of the text, but the text is going out of the box when the line breaks.
I tried adding textView.contentInset = UIEdgeInsetsZero
in textViewDidChange
method, but it continues to not work.
The function:
func textViewDidChange(textView: UITextView) {
let minSize = CGFloat(50)
let maxSize = UIScreen.mainScreen().bounds.height - 50 - keyboardHeight
let expectedSize = textView.contentSize.height + 9
var newSize = expectedSize < minSize ? minSize : expectedSize
newSize = newSize > maxSize ? maxSize : newSize
acessoryViewH.constant = newSize
textView.contentInset = UIEdgeInsetsZero
}
The auto-layout constraints: