From the course: iOS Development: Auto Layout Programmatically

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add a stack view

Add a stack view - iOS Tutorial

From the course: iOS Development: Auto Layout Programmatically

Start my 1-month free trial

Add a stack view

- [Instructor] There are some layouts that take just too many constraints. Think of a keyboard with dozens of buttons or a menu selection in a single row. These are cases where instead of using auto layout directly you used stack views. Stack views are arrays of views that auto layout makes the constraints for you, stacking one on top of the other or next to each other. Let's explore a stack view. Go ahead and stop the app. Head over to the Maki Rolls layout views. Once again it's nice and blank again. And add this one line of code. Let stackView equal UIStackView, parenthesis, and you'll find one that says arranged subviews. Go ahead and pick that one. Now the stack view is a special view of class UI stack view. It's initializer has a parameter of arranged subviews, which is an array of UI views. I'll make an array above this like the stack view. So we're gonna do let subviews and that will be an array of UIView, and I'll put four of our views in here. So I'll put imageView…

Contents