Please turn on JavaScript in your browser and refresh the page to view its content.
Availability 有効性
Technology
On This Page この項には
func background<S>(in shape: S, fillStyle: FillStyle = FillStyle()) -> some View where S : InsettableShape
FillStyle
View
InsettableShape
A view with the specified insettable shape drawn behind it.
shape
An instance of a type that conforms to InsettableShape that SwiftUI draws behind the view using the background shape style.
background
fillStyle
The FillStyle to use when drawing the shape. The default style uses the nonzero winding number rule and antialiasing.
This modifier behaves like background(_:in:fillStyle:), except that it always uses the background shape style to fill the specified insettable shape. For example, you can use a RoundedRectangle as a background on a Label:
background(_:in:fillStyle:)
RoundedRectangle
Label
ZStack { Color.teal Label("Flag", systemImage: "flag.fill") .padding() .background(in: RoundedRectangle(cornerRadius: 8)) }
Without the background modifier, the fill color shows through the label. With the modifier, the label’s text and icon appear backed by a shape filled with a color that’s appropriate for light or dark appearance:
To create a background with other View types — or with a stack of views — use background(alignment:content:) instead. To add a ShapeStyle as a background, use background(_:ignoresSafeAreaEdges:).
background(alignment:content:)
ShapeStyle
background(_:ignoresSafeAreaEdges:)
func background<V>(alignment: Alignment, content: () -> V) -> some View
func background<S>(S, ignoresSafeAreaEdges: Edge.Set) -> some View
func background(ignoresSafeAreaEdges: Edge.Set) -> some View
func background<S, T>(S, in: T, fillStyle: FillStyle) -> some View
func background<S>(in: S, fillStyle: FillStyle) -> some View
func listRowBackground<V>(V?) -> some View