When should you use frame-based layout versus Auto Layout?

When manual frames beat constraints.
Frames suit static or high-frequency UI like particle systems; Auto Layout handles rotation, Dynamic Type, localization, and split screen.
Claiming Auto Layout always wins.
WHAT THIS TESTS: This question probes whether you understand that UIKit offers two distinct layout paradigms and that senior engineers pick the right tool for the job rather than defaulting to the modern option. Interviewers want to hear that you grasp the performance characteristics of manual layout and the adaptive power of constraints.
A GOOD ANSWER COVERS: First, a crisp definition of frame-based layout as manually setting the origin and size of a view, typically in layoutSubviews or during animation blocks. Second, a clear explanation of Auto Layout as a constraint satisfaction system that calculates frames at runtime based on relationships between views, the superview, and intrinsic content size. Third, the specific domains where each wins: frames are ideal for static views, high-frequency updates like particle emitters or custom drawing, and performance-critical code where constraint solving overhead is unacceptable; Auto Layout is the right choice for adaptive interfaces that must respond to external changes like device rotation, split-screen multitasking, size classes, and internal changes like Dynamic Type, localization text expansion, or varying image aspect ratios. Fourth, the practical reality that most modern apps use Auto Layout for screens and frames for isolated high-performance subviews.
COMMON WRONG ANSWERS: Claiming that frame-based layout is deprecated or forbidden by Apple. Asserting that Auto Layout is always preferred because it is newer. Describing Auto Layout purely as a visual design tool rather than a runtime engine. Failing to mention intrinsic content size or content hugging and compression resistance. Saying you would use Auto Layout inside a tight animation loop without mentioning that updating constraints there causes expensive recalculations.
LIKELY FOLLOW-UPS: How would you animate a view laid out with Auto Layout? The expected path is to animate the constant of a constraint and call layoutIfNeeded inside an animation block. When would you mix the two approaches? A strong answer mentions using Auto Layout for the overall scene but frames for a custom rendering layer or a collection view cell that needs to hit 60 frames per second. How does Auto Layout interact with transforms? You should note that transforms operate on the rendered layer and do not affect the calculated frame, which can lead to clipping or misalignment if the constraint system is unaware of the visual change.
ONE CONCRETE EXAMPLE: Imagine a photo editing app with a scrolling filmstrip of thumbnails and a main canvas showing the selected image. The filmstrip and surrounding chrome should use Auto Layout so the interface adapts cleanly to iPad split screen, iPhone rotation, and localized button labels. The main canvas, however, might host a custom UIView subclass that draws a complex image with overlaid brush strokes at specific pixel coordinates. That canvas view uses frame-based layout because its content is not constraint-friendly, its geometry is fixed relative to its parent, and it may need to update at 60 or 120 frames per second during pinch-to-zoom without triggering a constraint solve.
Source: developer.apple.com
Read the original → developer.apple.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.