Auto Layout Knowledge
Kip Landergren
(Updated: )
My Auto Layout knowledge base explaining iOS’s view constraint solving layout engine.
Contents
Overview
Auto Layout is iOS’s mechanism of defining the spatial relationships of views within a view hierarchy, solving for a single solution that satisfies all of those relationships, and then rendering the solution on screen.
The constraint solving engine of Auto Layout takes the following inputs:
- explicit constraints
- sizing constraints
- views
- constraint priorities
- content priorities
- alignment rect insets
- horizontal, vertical and baseline alignments
- intrinsic content size
And outputs your application’s layout.
Core Idea
Define relationships between views as equations and solve that system of equations for a single solution that becomes the app’s layout.