Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill UIStackView by Ratio?

I have a horizontal UIStackView with 2 views within it. I'd like to have the left view take up ~70% of the screen, and the right view take up the remaining 30%. I know that I can set the UIStackView alignment to Fill and the distribution to Fill and that will allow me to have more control over my subview sizes. What I can't figure out is how to set the layout constraints/widths/etc. on the subviews so that the the 70/30 ratio is correct, particularly when the device is rotated?

Can anyone explain how to set the constraints on my subviews so that the 70/30 ratio is maintained across device rotations?

like image 252
Shadowman Avatar asked Oct 30 '22 05:10

Shadowman


1 Answers

You should be able to do this by creating an equal width constraint for the two views. Then, set the multiplier to that constraint to 0.7.

like image 157
Chris Garrett Avatar answered Nov 15 '22 06:11

Chris Garrett