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.
At a Glance
Auto Layout in Xcode 5 provides powerful workflows for rapidly and easily creating and maintaining constraint-based layouts in OS X and iOS apps. With Xcode 5, you can:
Add constraints when you are ready
Quickly add constraints using control-drag or menu options
Update constraints and frames separately
Specify placeholder constraints for dynamic views
See, understand, and resolve issues with conflicting constraints or ambiguous views
Organization of This Document
Read the following chapters to learn how to use Auto Layout:
Auto Layout Concepts to learn about the main concepts you need to understand when using Auto Layout
Working with Constraints in Interface Builder to learn about using Interface Builder to create and edit layout constraints
Working with Auto Layout Programmatically to learn about working with Auto Layout in code
Resolving Auto Layout Issues to learn about identifying and debugging issues with your layout
Auto Layout by Example to see examples of common Auto Layout use cases
Implementing a Custom View to Work with Auto Layout to learn how to implement a custom view that interoperates with Auto Layout
Adopting Auto Layout to learn how to adopt Auto Layout in an existing project that doesn’t use Auto Layout
Visual Format Language to learn about the language used to create constraints in code