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:
sizeThatFits(proposal:subviews:cache:): Calculates the overall container size for a proposed size.placeSubviews(in:proposal:subviews:cache:): Sets the exact $(x, y)$ coordinate bounds for each child subview.