Jacob
Jacob

Reputation: 121

textView constraints in scrollView

I have a textView which loads text from my server and I am trying to make it flexable in the scroll view and if the text is long it should expand and if text is short it comes back to the size of the text enter image description here

I did not tried any code because I think this is constraints issue

Upvotes: 0

Views: 391

Answers (2)

Zsolt Biró
Zsolt Biró

Reputation: 168

Set the constraints of the UITextView top, left, right and remove the bottom constraint and it should work.

Tested with Xcode 12.3 , Swift 5

Upvotes: 1

Farrukh Makhmudov
Farrukh Makhmudov

Reputation: 482

According to your question, you using Autolayout. Perfect!

So if you want to fit your TextView size to its content. You should uncheck on your storyboard (of textView),

enter image description here

Or by code:

textView.scrollEnabled = false

p.s. be sure that you created constraints correctly in your storyboard

Upvotes: 0

Related Questions