Auto Layout Guide

Introduction

Important: This is a preliminary document for an API or technology in development. Apple is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein for use on Apple-branded products. This information is subject to change, and software implemented according to this document should be tested with final operating system software and final documentation. Newer versions of this document may be provided with future betas of the API or technology.

Auto Layout is a system that lets you lay out your app’s user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of constraints either on individual elements, or between sets of elements. Using Auto Layout, you can create a dynamic and versatile interface that responds appropriately to changes in screen size, device orientation, and localization.

Auto Layout is built into Interface Builder in Xcode 5, and is available to apps targeted at either iOS and OS X. Auto Layout is enabled by default when you create a new project. If you have an existing project that doesn’t use Auto Layout, read Adopting Auto Layout.

The typical workflow for creating user interfaces starts by using Interface Builder to create, reposition, resize, and customize your views and controls. When you are satisfied with the positions and settings, you’re ready to start adding Auto Layout constraints so that your interface can react to changes in orientation, size, and localization.