Auto Layout: Describing Relationships, Not Frames

Auto Layout lets you describe a UI by its relationships, not hardcoded coordinates. You declare "this button is centered and 8 points below the logo," and the system calculates its position.
Why it exists
To create adaptive user interfaces that respond dynamically to changes without manual frame calculation. Before Auto Layout, developers had to write code to manually recalculate the size and position of every view when the screen rotated or content changed, which was brittle and complex.
The mental model
Think of Auto Layout as a declarative system for describing relationships between views. Instead of telling a view where to be (e.g., at coordinate 100, 200), you tell it how to relate to other views (e.g., "be centered horizontally in your parent" and "be 8 points below the title label"). The layout engine then solves these equations to determine the final frames.
How it works
Auto Layout builds a view hierarchy and solves a system of linear equations based on the constraints you provide. Each constraint, like button.top = image.bottom + 8, is an equation. The system calculates the x, y, width, and height for every view that satisfies all constraints simultaneously. This happens automatically whenever a change, like a device rotation, invalidates the current layout.
When to use it
Use Auto Layout for any modern iOS, iPadOS, or macOS app. It's essential for handling external changes like different screen sizes (iPhone SE vs. Pro Max), device rotation, and multitasking features like Split View. It's also critical for internal changes like supporting Dynamic Type (user-adjustable font sizes) and internationalization, where text labels can drastically change in length (e.g., English vs. German).
When not to use it
While it's the default, you might temporarily opt-out for performance-critical custom drawing or animations where you need absolute control over every frame, but this is rare. For very simple parent-child resizing, older autoresizing masks can work, but Auto Layout is far more powerful and expressive for building a truly adaptive interface.
One canonical example
A login screen has a logo and a "Login" button. You constrain the logo to be centered horizontally and 20 points from the top. You then constrain the button to also be centered horizontally and 16 points below the logo's bottom edge. Now, if the device rotates or the app runs on a larger iPad, the logo and button automatically adjust their positions to remain centered and correctly spaced, with no extra code needed.
Interview question
Which statement best describes the fundamental mental model of Auto Layout?
- a.Creating separate, static layouts for each device type and orientation.
- b.Employing a hierarchical grid system to automatically position elements.
- c.Specifying precise pixel coordinates and dimensions for every UI element.
- d.Declaring how UI elements relate to each other through a system of constraints.Correct
Why? this is the answer
Auto Layout's core mental model is about describing relationships between views (e.g., '8 points below the logo') rather than setting fixed frames. Option C describes the manual frame calculation that Auto Layout replaced, making it a tempting but incorrect distractor.
Just read this? Test yourself on what you have been reading.
Read the original → developer.apple.com
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on ios — each one lists the topics its interview covers.
See open roles