SwiftUI.cc
SwiftUI collection

Layout SwiftUI reference, page 2

Continue browsing SwiftUI layout examples and API notes.

Showing 10-14 of 14 reference pages
PreviousPage 2 of 2

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.

5 min readOpen

ViewThatFits tries each child in order and renders the first one that fits the proposed space — declarative responsive layout without measuring anything yourself.

4 min readOpen

containerRelativeFrame sizes a view as a fraction of its nearest container — full width, one-of-three columns, or custom math — without GeometryReader.

4 min readOpen

Modern ScrollView is configured declaratively: scrollTargetBehavior for paging and snapping, scrollPosition for tracking, contentMargins for insets, plus bounce and disable controls.

5 min readOpen

ScrollViewReader exposes a proxy whose scrollTo(_:anchor:) jumps to any child with an id — chat bottoms, section indexes, and back-to-top buttons.

4 min readOpen