Ios – Set height constraint for UITextView

autolayoutiosuitextview

I'm fairly new to iOS development and am having a hard time sizing a UITextView to it's content. I've found several examples of calculating a strings render size and/or updating the frame size of a textview, however I can't seem to get those to work.

When I add a UITextView to my view it adds a Height constraint which I think is locking it to a specific height. How can I work around it, update the constraint via code, and/or get my UITextView to resize vertically to show my content?

Best Answer

You can create an outlet to the vertical size constraint, and then adjust the .constant property of the constraint to amend the height of your text view.