Instance Method

edgesIgnoringSafeArea(_:)

Change the view’s proposed area to extend outside the screen’s safe areas.

Declaration

func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View

Parameters

edges

The set of the edges in which to expand the size proposed for this view.

Return Value

A view that accepts the size proposed for it, extends that size out of the safe area on the edges specified by edges, proposes that area to this view, and centers this view.

Discussion

Use edgesIgnoringSafeArea(_:) to change the area proposed for this view so that — were the proposal accepted — this view could extend outside the safe area to the bounds of the screen for the specified edges.

For example, you can propose that a text view ignore the safe area’s top inset:

VStack {
    Text("This text is outside of the top safe area.")
        .edgesIgnoringSafeArea([.top])
        .border(Color.purple)
    Text("This text is inside VStack.")
        .border(Color.yellow)
}
.border(Color.gray)

If this view does not accept the size proposed for it, it is positioned in the center of the proposed area.

A screenshot showing a view whose bounds exceed the safe area of the screen.

See Also

Positioning a View

func position(CGPoint) -> View

Positions the center of this view at the specified point in its parent‘s coordinate space.

func position(x: CGFloat, y: CGFloat) -> View

Positions the center of this view at the specified coordinates in its parent’s coordinate space.

func offset(CGSize) -> View

Offset the view by the horizontal and vertical amount specified in the offset parameter.

func offset(x: CGFloat, y: CGFloat) -> View

Offset this view by the specified horizontal and vertical distances.

func coordinateSpace<T>(name: T) -> View

Assigns a name to the view’s coordinate space, so other code can operate on dimensions like points and sizes relative to the named space.