Mastering the Three Phases of iOS Layout with Auto Layout

Swift programming

Steven Curtis
2 min readApr 25, 2023
Photo by Jake Hills on Unsplash

Before we start

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 12.2, and Swift 5.3

Keywords and Terminology:

Auto Layout: A constraint-based layout system

intrinsicContentSize: The natural size for the receiving view, considering only properties of the view itself

Superview: The superview is the immediate ancestor of the current view

Subview: The subview is a child of the current view

The Three Phases to Display a View

In order to display a view there are three phases:

- update constraints

- update layout

- update display

Step 1: Updating Constraints

Constraints are calculated that set the frame of views, from each subview to superview (so moving up the hierarchy). This can be triggered by calling setNeedsUpdateConstraints, or through any changes to constraints.

--

--