Autolayout

In iOS, our UI elements are placed onscreen with an autolayout 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 (original iPhone through iPhone 4s), 4-inch models (iPhone 5, 5c, and 5s), the 4.7-inch iPhone 6, and 5.5-inch iPhone 6 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 our label and button to be horizontally centered, and we don’t care ...

Get iOS 9 SDK Development 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.