Search code examples
iosuiviewautolayoutuitextviewxcode-storyboard

How to change uiview's height using auto layout?


So I created this scenario in order to understand how views increase in height according to their content. However am still not able to make it happen.

This is what I have now:

enter image description here

the textview is growing according to content. however the uiview containing it is disappearing. what constraints should I use so that when the uitextview becomes bigger, its parent view also increase in height?


Solution

  • ON UITextView make your you unselected These

    • Scrolling Enabled
    • Bounces
    • Bounce Horizontally
    • Bounce Vertically
    • Shows Horizontal Indicator
    • Shows vertical indicator

    Now Change your auto layout constraints like this.

    enter image description here

    Constraints for parent view