Declaration
compose().backgroundStyle(style: SwiftUI.ShapeStyle)nonisolated func backgroundStyle<S>(
_ style: S
) -> some View
where S : ShapeStyleParameters
style*SwiftUI.ShapeStyle
Discussion
The following example uses this modifier to set the
EnvironmentValues.backgroundStyle environment value to a
ShapeStyle.blue color that includes a subtle Color.gradient.
SwiftUI fills the Circle shape that acts as a background element
with this style:
Image(systemName: "swift")
.padding()
.background(in: Circle())
.backgroundStyle(.blue.gradient)To restore the default background style, set the
EnvironmentValues.backgroundStyle environment value to
nil using the View.environment(_:_:) modifer:
.environment(\.backgroundStyle, nil)See also
More in Styles.
- arrangementViewStyleSets the style for arrangement views within this view.
- buttonStyleSets the style for buttons within this view to a button style with a custom appearance and custom interaction behavior.
- controlGroupStyleSets the style for control groups within this view.
- datePickerStyleSets the style for date pickers within this view.
- disclosureGroupStyleSets the style for disclosure groups within this view.
- foregroundStyleSets the primary, secondary, and tertiary levels of the foreground style.
- formStyleSets the style for forms in a view hierarchy.
- gaugeStyleSets the style for gauges within this view.
- groupBoxStyleSets the style for group boxes within this view.
- indexViewStyleSets the style for the index view within the current environment.
- labeledContentStyleSets a style for labeled content.
- labelStyleSets the style for labels within this view.