The insets of a content margin guide for the given edges.
Read a guide when you need its value rather than the inset, like a
view that draws its own content:
GeometryReader { proxy in
Canvas { context, size in
drawChart(
in: context, size: size,
insets: proxy.contentMargins(for: .container, edges: .horizontal))
}
}
- Parameters:
- guide: The guide that provides the insets.
- edges: The edges to read insets for.
- Returns: The insets `guide` provides for `edges`. Edges not in the
set have a value of zero.
Returns the reserved regions for the given kind.
A reserved region indicates that an area within a view's coordinate
space has been claimed by something the view does not own. The view
should arrange its content to account for this region. Each region
describes a frame, margins, active state, and an identifier.
Regions are categorized by their kind, ``ReservedRegion.Kind``. There
are two kinds of reserved regions:
- ``ReservedRegion.Kind/occlusion``: An area that is occluded by an
element, such as a Dynamic Island, a camera or window controls.
- `division`: An area where content should split into separate regions,
such as at the fold of a hinge.
You read reserved regions using the
``GeometryProxy/reservedRegions(kind:)`` method. This method returns
all of the reserved regions that currently intersect your view
regardless of whether they are currently active.
In the example below, the reserved regions are passed to a custom
``Layout`` which handles positioning its subviews away from any
regions that intersect it.
GeometryReader { proxy in
RegionAvoidingLayout(
regions: proxy.reservedRegions(kind: .occlusion)
) {
ForEach(items) { item in
ItemView(item)
}
}
}
When manually positioning your content to incorporate
reserved regions, take care to consider right to left layout
directions. Reserved regions are often in a fixed coordinate
space; the absolute location of the camera of a device does not flip
depending on the user's preferred language. By default, the system
mirrors the geometry of these regions to automatically handle
being provided to most SwiftUI APIs.
For example, a ``Layout`` will automatically flip the geometry of the
subviews you place. By mirroring the geometry of the reserved regions,
your layout does not need to account for the layout direction when
determining whether a particular subview will intersect the region.
There may be cases when you need to make more manual adjustments for
the frames of reserved regions for right to left layout directions.
In these cases, you can provide the ``LayoutDirectionBehavior/fixed``
value to the method and the system will not mirror the frames of the regions.
proxy.reservedRegions(
kind: .occlusion, layoutDirectionBehavior: .fixed)
Returns the concentric corner radii for the specified frame relative to
the container shape.
Concentric corners share the same center point as the container's
corners. The radius for each corner is calculated as the container's
corner radius minus the distance from the frame's corner to the
container's corner.
Unlike ``ConcentricRectangle``, which calculates and draws the shape,
this function only returns the calculated radii. Use this when you need
corner radii for a subregion of the view, or when you want to use the
values for custom drawing, animations, or other purposes:
GeometryReader { geometry in
Canvas { context, size in
let rect = CGRect(x: 10, y: 10, width: 80, height: 80)
if let radii = geometry.concentricCornerRadii(in: rect) {
let path = Path(roundedRect: rect, cornerRadii: radii)
context.fill(path, with: .color(.blue))
}
}
}
.containerShape(.rect(cornerRadius: 48))
- Parameter frame: The frame in the view's local coordinate space for
which to calculate the concentric corner radii.
- Returns: The resolved corner radii, or `nil` if no container shape
is set or the shape does not provide sufficient corner info.
- SeeAlso: ``ConcentricRectangle``
get · iOS 27.0+
concentricCornerRadii
TypeScript
get concentricCornerRadii(): (RectangleCornerRadii) | null
Swift declaration
var concentricCornerRadii: RectangleCornerRadii? { get }
The concentric corner radii for this view's bounds relative to the
container shape.
Concentric corners share the same center point as the container's
corners, creating visually harmonious nested rounded rectangles. The
radius for each corner is calculated as the container's corner radius
minus the distance from this view's corner to the container's corner.
Unlike ``ConcentricRectangle``, which calculates and draws the shape,
this property only returns the calculated radii. This allows you to use
the values for custom drawing, animations, or other purposes:
GeometryReader { geometry in
Canvas { context, size in
if let radii = geometry.concentricCornerRadii {
let path = Path(
roundedRect: CGRect(origin: .zero, size: size),
cornerRadii: radii
)
context.fill(path, with: .color(.blue))
}
}
}
.containerShape(.rect(cornerRadius: 48))
Each corner's radius depends on its position relative to the container:
- Corners aligned with the container's corners get concentric radii
- Corners far from the container's corners get zero radii
- The radius is clamped to the view's maximum possible radius
- Returns: The resolved corner radii, or `nil` if no container shape
is set or the shape does not provide sufficient corner info.
- SeeAlso: ``ConcentricRectangle``
get · iOS 26.0+
containerCornerInsets
TypeScript
get containerCornerInsets(): RectangleCornerInsets
Swift declaration
var containerCornerInsets: RectangleCornerInsets { get }
Returns the corner insets of the container view. Use this value to
adjust the geometry of a view based on the overlapping corner insets of
the container view. Corner insets may include pieces of system UI as
well as the corner radii for windows and presentations.
GeometryReader { geometry in
NavigationTitleView()
.offset(x: geometry.containerCornerInsets.topLeading.width)
}
Container corner inset sizes may not be uniform. For example, on iPadOS
and macOS, when the window fills the entire screen without displaying
window controls, the inset sizes will always be zero. When that window
does display window controls, and the view overlaps the window control
area, the corner inset size for the top leading corner will be the size
of the overlapping area.