SwiftUI reference pages, page 3
Continue browsing practical SwiftUI examples, API notes, pitfalls, and implementation checklists.
Pass child measurements up the view tree with PreferenceKey when a parent needs information children know first.
Represent unavailable, loading, private, and pass-through states with the right interaction and visual modifiers.
HStack lays out children left to right with a shared vertical alignment. layoutPriority decides which child shrinks first when space runs out.
ZStack overlays children back to front with a shared alignment. Combine it with ignoresSafeArea for full-bleed backgrounds without pushing content under the notch.
Grid aligns cells into true rows and columns, sizing each column to its widest cell. gridCellColumns spans columns and gridCellUnsizedAxes stops decoration from inflating the grid.
Spacer is a flexible blank view that absorbs leftover space along a stack's axis. Use minLength to keep a guaranteed gap and multiple Spacers for proportional layouts.
GeometryReader hands you the size and frame proposed by the parent so children can adapt. Read frames in .local, .global, or named coordinate spaces — and reach for it sparingly.
ViewThatFits tries each child in order and renders the first one that fits the proposed space — declarative responsive layout without measuring anything yourself.