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.

The alignment property and size

The alignment property and size - iOS Tutorial

From the course: iOS Development: Auto Layout Programmatically

Start my 1-month free trial

The alignment property and size

- You've made a basic stackView. There's two powerful properties which can make stackViews do a lot more than some simple equally sized buttons. The alignment and distribution. Let's look at alignment first. This will be far easier to understand without that image. Images are static and won't do everything we want it to do. So I'm gonna remove it for now. Stop the app. Close up the console. Find the addViews method. You'll find there a method called addImageView. Just comment that out. You'll see layoutViews is not far below it. Just delete the imageView. And our imageView will now disappear for the moment. In a stackView, alignment is perpendicular to the axis. For a vertical axis, I get horizontal alignment. For a horizontal axis, vertical alignment. Where you see fill in the code for alignment, just put a dot there. So we can get the auto-complete. You'll see a whole bunch of different options for the alignment. Leading, trailing, and center are viable options for horizontal axis…

Contents