View ModifieriOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+
Overloads
3 ways to call compose().safeAreaPadding(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().safeAreaPadding(
edges?: SwiftUI.EdgeSet,
length?: number | null
)@export(implementation) nonisolated func safeAreaPadding(
_ edges: Edge.Set = .all,
_ length: CGFloat? = nil
) -> some ViewParameters
edgesSwiftUI.EdgeSetlengthnumber | null
Discussion
Use this modifier when you would like to add a fixed amount of space to the safe area a view sees.
ScrollView(.horizontal) {
HStack(spacing: 10.0) {
ForEach(items) { item in
ItemView(item)
}
}
}
.safeAreaPadding(.horizontal, 20.0)See the horizontal
View.safeAreaInset(edge:alignment:spacing:content:)-(HorizontalEdge,_,_,_)
or vertical
View.safeAreaInset(edge:alignment:spacing:content:)-(VerticalEdge,_,_,_)
modifier for adding to the safe area based on the size of a view.
See also
More in Layout.
- alignmentGuideSets the view's vertical alignment.
- aspectRatioConstrains this view's dimensions to the specified aspect ratio.
- containerCornerOffsetAdjusts the view's layout to avoid the container view's corner insets for the specified edges.
- containerRelativeFramePositions this view within an invisible frame with a size relative to the nearest container.
- controlSizeSets the size for controls within this view.
- defaultScrollAnchorAssociates an anchor to control which part of the scroll view's content should be rendered by default.
- dynamicTypeSizeSets the Dynamic Type size within the view to the given value.
- fixedSizeFixes this view at its ideal size.
- flipsForRightToLeftLayoutDirectionSets whether this view mirrors its contents horizontally when the layout direction is right-to-left.
- framePositions this view within an invisible frame.
- geometryGroupIsolates the geometry (e.g. position and size) of the view from its parent view.
- gridCellAnchorSpecifies a custom alignment anchor for a view that acts as a grid cell.