Ian Bell Ian Bell - 4 months ago 53
iOS Question

How to correctly configure my stackview?

I drag a vertical UIStackView in my storyboard, I constrain it vertically and horizontally and give it fixed dimensions, 300x300.

Inside this stackview, I put:

  1. a UIImageView (Aspect Fit)

  2. an horizontal stackview containing two buttons

I have no problems if I equally space the content inside the main stackview, but it's not what I want.

I want the imageview to take 70% of the vertical space, leaving the other 30% to the buttons.

This should be the result

I tried using
Fill proportionally
on the main stackview, but, while in the storyboard is anything ok, when I test on simulator the two buttons totally disappear and I only see the imageview with its content.

What am I doing wrong?


I've recorded a short video

Basically you need to set the height of the image to be equal to 70% of the stackview height. Hope it'd help