This doc distills layout and scrolling guidance from Fatbobman SwiftUI articles. It focuses on layout, sizing, alignment, stacks/grids, safe areas, overlays/backgrounds, and scrolling/lazy containers.
- Learn the size pipeline (proposed size, required size, layout size, view size) so you know why
frameand measuring can behave unexpectedly. Source: https://fatbobman.com/en/posts/layout-dimensions-1/ - Similar-looking layouts can have different layout semantics. Use
frameandfixedSizewith intent, and prefer the container that matches the layout contract you want. Source: https://fatbobman.com/en/posts/layout-dimensions-2/ - Use the simplest layout tool that meets the requirement:
offset,alignmentGuide,layoutPriority, andScrollViewcan all solve the same UI, but they affect layout differently. Source: https://fatbobman.com/en/posts/layout-in-swiftui-way/ - Centering can be done via
Spacer,frame(alignment:),overlay, orGeometryReader.