A function that receives a GeometryProxy and returns a component. The proxy provides the container’s size, safe area insets, and frame information.
GeometryProxy
Thegeometry parameter passed to the content function has the following properties:
The container’s size in points.
The safe area insets of the container.
Corner insets for rounded container shapes (e.g. device corners).
Methods
Returns the frame rectangle in the given coordinate space. CoordinateSpace is one of
"global" (relative to the screen), "local" (relative to the component itself), "scrollView" (relative to the nearest scroll view), or any custom string registered via .coordinateSpace().Returns the bounds of a named coordinate space, or an empty object if unavailable.
Support
Usage
Proportional sizing
Size a child relative to the available space:Responsive layout
Choose a layout based on the available width:Using frame coordinates
Access the component’s position in global coordinates:Notes
- GeometryReader expands to fill all available space in its parent container. This can affect layout if not accounted for.
- Use GeometryReader sparingly. For adaptive layouts, consider ViewThatFits as a simpler alternative that does not expand to fill space.
- The
frame()method returns a GeometryRect withminX,minY,maxX,maxY,width,height,midX, andmidYproperties.
See Also
- ViewThatFits — adaptive layout without geometry access