struct ToggleStyleConfiguration
The properties of a toggle instance.
Availability 有効性
Technology
init(_ configuration: ToggleStyleConfiguration
)
Label
is ToggleStyleConfiguration.Label
.configuration
The properties of the toggle, including a label and a binding to the toggle’s state.
You can use this initializer within the make
method of a Toggle
to create an instance of the styled toggle. This is useful for custom toggle styles that only modify the current toggle style, as opposed to implementing a brand new style.
For example, the following style adds a red border around the toggle, but otherwise preserves the toggle’s current style:
struct RedBorderToggleStyle: ToggleStyle {
func makeBody(configuration: Configuration) -> some View {
Toggle(configuration)
.padding()
.border(.red)
}
}
struct ToggleStyleConfiguration