iOS Platform & SwiftUI (50 Qs)•Part 2: Combine, Persistence, Security & Networking (11 - 24)
How does SwiftUI Layout and GeometryReader work internally?
senior LevelSecurity & Auth
In Simple Words: SwiftUI layout operates in 3 distinct phases:
- Parent proposes a size to the child view.
- Child chooses its own size based on its content proposals.
- Parent places the child within its coordinate space.
GeometryReaderTrap: AGeometryReadereagerly expands to fill all available space proposed by its parent!- Using
GeometryReaderindiscriminately destroys intrinsic content sizing and causes layout bugs; use.visualEffector customLayoutprotocol instead in iOS 17+.