Return Value 戻り値
A view with the background
shape style drawn behind it.
Availability 有効性
Technology
A view with the background
shape style drawn behind it.
edges
The set of edges for which to ignore safe area insets when adding the background. The default value is all
. Specify an empty set to respect safe area insets on all edges.
This modifier behaves like background(_:
, except that it always uses the background
shape style. For example, you can add a background to a Label
:
ZStack {
Color.teal
Label("Flag", systemImage: "flag.fill")
.padding()
.background()
}
Without the background modifier, the teal color behind the label shows through the label. With the modifier, the label’s text and icon appear backed by a region filled with a color that’s appropriate for light or dark appearance:
If you want to specify a View
or a stack of views as the background, use background(alignment:
instead. To specify a Shape
or Insettable
, use background(_:
or background(_:
, respectively.