Search code examples
iosswiftautolayoutuikitconstraints

Resize UIView in XIB depending on subviews size


I have a layout (see image) made out of a few stack views embedded in each other, which are all subviews of the big pink UIView and I wanted to know how to automatically size the big pink UIView depending on the contents of it since the three labels in the middle stack view may become multiline in the future (the whole view's width is constant). Thanks!

Image of layout:

enter image description here


Solution

  • Never mind, turns out the view does size itself already, because I constrained the height of the button and the little title stack view at the top and not the middle stack view. Don't really know how this works, but it does!