skip to Main Content

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

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search