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?
Stack views let you leverage the power of Auto Layout, creating user interfaces that can dynamically adapt to the device's orientation, screen size, and any changes in the available space. The stack view manages the layout of all the views in its arrangedSubviews property.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With