Say for example I want to add 3 buttons to a stack view.
Button1 is 200 * 200 (1)
Button2 is 150 * 150 (0.75)
Button3 is 100 * 100 (0.5)
How can I accomplish this in interface builder?
Say for example I want to add 3 buttons to a stack view.
Button1 is 200 * 200 (1)
Button2 is 150 * 150 (0.75)
Button3 is 100 * 100 (0.5)
How can I accomplish this in interface builder?
You can do it in the storyboard using stackview
The set up is shown in fig:
You are having conflicts because of Alignment Property which in your case it fill. make is center and its done.
Also we can add spacing between buttons. If we set Distribution Equal Spacing and add height constraint to stackview with height more than height of buttons.
This is vertical stackview. You can test the same with horizontal stackview.
Hope it will work for you.
UIView's
. I've tried the same approach for UIView
even I've given same constraint values. Thought when I changed them to UIButton
. It was working. Can some one suggest how to make the same to work for UIView
. Alignment = center
doesn't help either. –
Casta For those who are looking a solution for UIView
, Here it is,
UIStackView ensures that its arranged subviews maintain the same proportion to each another as your layout grows and shrinks. However, unlike the other distribution options, views that are proportional must have an intrinsic content size.
© 2022 - 2024 — McMap. All rights reserved.