How Can I have multiple widths and heights of subviews in a UIStackView
You can do it in the storyboard using stackview
- Add a stackview with Alignment Center and Distribution Fill.
- Constraints on stackview is center horizontally and center vertically.
- Now add three buttons.
- Constraints on button1 is height and width = 200
- Constraints on button2 is height and width = 150
- Constraints on button3 is height and width = 100
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.