DevPrep

All topics › UIKit

Auto Layout

Junior PRO

The gist

Auto Layout is UIKit's layout engine that computes every view's frame from a set of rules called constraints. A constraint is a linear equation or inequality between attributes of two views (a.leading = b.trailing + 8, width >= 44), and each one has a priority from 1 to 1000. The engine (a variant of the Cassowary algorithm) solves the whole system and assigns frames during the layout phase.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store