When i am pasting the text in UITextView
then some extra space is getting added into it. But when i scroll it then the textView
is fitted according to the content. In textViewDidChange
, textView
height constraint is being set according to its content size. Anybody faced the same issue?
func textViewDidChange(_ textView: UITextView) {
let newSize = textView.sizeThatFits(CGSize.init(width: textView.frame.size.width, height: CGFloat(MAXFLOAT)))
textView.isScrollEnabled = false
if newSize.height < 37 {
self.messageTextViewHeightConstraint.constant = minimumTextviewHeight
}
if (newSize.height >= 37 && newSize.height <= 100) {
self.messageTextViewHeightConstraint.constant = newSize.height
}
if (newSize.height >= 100) {
self.messageTextViewHeightConstraint.constant = maximumTextviewHeight
self.textView.isScrollEnabled = true
}
}