Placing UI Elements with Auto Layout

In iOS, our UI elements are placed onscreen with an auto layout system that lets you determine where objects should go and how big they should be based on constraints that we set on them. This allows our interfaces to adapt to being rotated between portrait and landscape, and to handle the differing screen sizes of the 3.5-inch models (iPhone 4s), 4-inch models (iPhone 5, 5c, 5s, and SE), 4.7-inch models (iPhone 6, 6s, and 7), and 5.5-inch models (iPhone 6 Plus, 6s Plus, and 7 Plus). Constraints allow us to express what matters to us—the size of components, their alignment with or distance from other components, and so forth—and to let other factors vary as needed.

In this example, we want to put the Play ...

Get iOS 10 SDK Development, 1st Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.