How to resize subviews of UIStackView in Xcode?

Jim Moody picture Jim Moody · Dec 12, 2015 · Viewed 9.8k times · Source

Every time I try to add something to a UIStackView in iOS it autosizes my subviews into something that is too small, so the text is being cut off.

How exactly is this StackView supposed to be used? All the guides said it was easy, just drag your subviews inside it, but I must be doing something wrong..

Before adding to StackView:

Before adding to StackView

After Adding to StackView:

After Adding to StackView

Answer

Irfan picture Irfan · Dec 12, 2015

This is because stackview itself needs constraints. Add constraints to your stackview and then the stackview will take care of subviews.

enter image description here

In this case stackview is positioned horizontally and vertically center in container.

Let me know if there is still any issue.