Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize subviews of UIStackView in Xcode?

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

like image 669
Jim Moody Avatar asked Dec 12 '15 17:12

Jim Moody


Video Answer


1 Answers

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.

like image 62
Irfan Avatar answered Sep 17 '22 19:09

Irfan