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.

Welcome to The infinite monkey theorem

Somewhere a monkey just typed Shakespeare in TypeScript. Be the first to read the masterpieces (and the hilarious misfires) landing on the blog.

Subscribe to The infinite monkey theorem

We fling fresh posts—no banana peels attached—straight to your inbox.