I want to create UITextView that can resize and scroll at the same time like the ones on Telegram , Instagram or Whats App that allow UITextView to grow up to or 8 lines then you can scroll if you add more text to it I was able to make the UITextView grow to 5 line but if they are more text I can not see since the isScroll property is disabled
my UITextView is inside UIView with two button on the left and right and I would prefer to do it through constrain if that’s possible if not through code is fine too
2
Answers
You can achieve your expected outcome by following steps:
Here below I am attaching code snippet, which may help you:
Sagar‘s answer is great, but I want to enhance it a bit and add some animation to it:
the steps you need
textViewDidChange
delegate method of the textViewtextViewDidChange
textView.sizeThatFits(size)
here is an example