跳转至
Structure

SafeAreaRegions

A set of symbolic safe area regions.

Declaration

@frozen struct SafeAreaRegions : OptionSet

Overview

Use this option set with the ignoresSafeArea(_:edges:) view modifier to specify which edges of a view should ignore which safe areas.

Safe area options:

  • container: The top and bottom safe portions of the screen, like the status bar.
  • keyboard: The portion of the screen covered by a software keyboard

struct SafeAreaIgnoringView: View {
    var body: some View {
        ZStack {
            Color.pink
            Text("I am everywhere (except the software keyboard)")
        }
        .ignoresSafeArea(SafeAreaRegions.container, edges: [.top, .bottom])
    }
}
A screenshot displaying a pink background that extends to every edge of the screen, with text in the center that reads "I am everywhere (except the software keyboard)." The ignoresSafeArea view modifier is applied to specify which edges should ignore safe areas, in this case top and bottom.

Availability

iOS 14.0+

macOS 11.0+

tvOS 14.0+

watchOS 7.0+

Topics


Type Alias

ArrayLiteralElement The type of the elements of an array literal.

Element The element type of the option set.

RawValue The raw type that can be used to represent all values of the conforming type.


Initializer

init(rawValue:) Creates a new option set from the given raw value.


Type Property

all All safe area regions.

container The safe area defined by the device and containers within the user interface, including elements such as top and bottom bars.

keyboard The safe area matching the current extent of any software keyboard displayed over the view content.


Instance Property

rawValue The corresponding value of the raw type.