K Man
K Man

Reputation: 628

How can I adjust the distribution of my Stack View for unequal view sizes?

Here is what I have so far for my Main.Storyboard, along with the View Controller Scene hierarchy and Stack View settings.

Main.Storyboard

Right now, everything scales correctly for each device and orientation. The problem is when I attempt to adjust the stack view distribution. I want the middle "CLICK" button to be a little smaller and for the UIImageView to be slightly larger. Changing the distribution setting to "Fill" or "Fill Proportionally" didn't help. It simply cut off the top pencil view when I ran the app. Manually adjusting the top, middle and bottom view sizes doesn't help either.

Upvotes: 0

Views: 1113

Answers (1)

DonMag
DonMag

Reputation: 77690

Set your Stack View's Distribution to Fill

Give the Top view a height constraint equal to the height of the stack view, with a multiplier of 0.4

Give the Bottom view a height constraint equal to Top

And that should do it!

Edit

Ctrl-click-drag from Top to Stack View, select Equal Heights:

enter image description here

Ctrl-click-drag from Bottom to Top, select Equal Heights:

enter image description here

Select Top and edit the Height constraint in the Size Inspector pane:

enter image description here

Select Bottom and edit the Height constraint in the Size Inspector pane:

enter image description here

Upvotes: 1

Related Questions