Shawjak3
Shawjak3

Reputation: 541

How to make a UIView's height not restricted in Interface Builder

I have a UIView that has a height of 40. But I have a UILabel inside of that that could be one line or multiple. How do I make the UIView resize depending on that? I am open to doing this in Swift if I need to but if there is a way in Interface Builder that would be better.

Upvotes: 0

Views: 90

Answers (1)

Doro
Doro

Reputation: 2413

  1. add top, left, right , bottom constraints via IB for your label and set number of lines to 0

enter image description here

  1. Add flexible height for your container view ( add height constraint and change it to be Greater then or equal) enter image description here

  2. Now, if you set long test - it will automatically extend container view :

enter image description here

Upvotes: 2

Related Questions