11
Stack Views

You have been using Auto Layout throughout this book to create flexible interfaces that scale across device types and sizes. Auto Layout is a very powerful technology, but with that power comes complexity. Laying out an interface well often needs a lot of constraints, and it can be difficult to create dynamic interfaces due to the need to constantly add and remove constraints.

Often, an interface (or a subsection of the interface) can be laid out in a linear fashion. Think about the other applications you wrote: The Quiz application from Chapter 1 consisted of four subviews that were laid out vertically. And in the WorldTrotter application, the ConversionViewController had a vertical interface consisting of a text field and a few labels.

Interfaces that have a linear layout are great candidates for using a stack view. A stack view is an instance of UIStackView that allows you to create a vertical or horizontal layout that is easy to lay out and manages most of the constraints that you would typically have to manage yourself. Perhaps best of all, you are able to nest stack views within other stack views, which allows you to create truly amazing interfaces in a fraction of the time.

In this chapter, you are going to update LootLogger to display the details of a specific Item. The interface that you create will consist of multiple nested stack views, both vertical and horizontal (Figure 11.1). In Chapter 12, you will implement editing and finish the interface.

Figure 11.1  LootLogger with stack views

LootLogger with stack views
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.66.178