Stack views vertically or horizontally on iOS 8 using AutoLayout
While starting iOS 9 we have UIStackView, it is a little bit tricky to stack views vertically or horizontally.
While starting iOS 9 we have UIStackView, it is a little bit tricky to stack views vertically or horizontally on iOS 8 using AutoLayout and without using any helper views.
For a horizontal arrangement the trick is to position the views and add “Align Center X to superview” to all subviews that we want to stack. Constraint’s Constant should be set to 0 and Multiplier should be set to adjust view’s position relative to the center.
For example to position 2 views the multiplier can be set to 3:5 for the first view and 7:5 for the second view.
Subscribe to The infinite monkey theorem
Get the latest posts delivered right to your inbox