Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 2: Combine, Persistence, Security & Networking (11 - 24)

42%
iOS Platform & SwiftUI (50 Qs)•Part 2: Combine, Persistence, Security & Networking (11 - 24)

What is the `Layout` protocol in SwiftUI (iOS 16+)?

junior LevelSecurity & Auth

In Simple Words: Allows creating custom container layouts (e.g. Masonry, FlowLayout, Radial layouts) without falling back to UIKit:

  • Requires implementing two methods:
    1. sizeThatFits(proposal:subviews:cache:): Calculates the overall container size for a proposed size.
    2. placeSubviews(in:proposal:subviews:cache:): Sets the exact $(x, y)$ coordinate bounds for each child subview.