跳转至
Structure

BackgroundStyle

A style that looks solid white in light mode and solid black in dark mode.

Declaration

@frozen struct BackgroundStyle

Overview

Use this ShapeStyle to intelligently stroke and fill shapes based on what color will look good against the current background.

In light mode, this will fill as solid white. In dark mode, it will fill as solid black.

In the following example, the top circle is always invisible, since it is filled the same color as the background.

struct CircleOnButtomView: View {
    var body: some View {
        Circle()
            .fill(BackgroundStyle())
        Circle()
    }
}
A view containing two circles, one filled background style, making it invisible, and the other with default black fill.

Availability

iOS 14.0+

macOS 11.0+

tvOS 14.0+

watchOS 7.0+

Topics


Initializer

init() Creates a new background style.