static var automatic: DefaultToggleStyle
Self
is DefaultToggleStyle
.static var button: ButtonToggleStyle
Self
is ButtonToggleStyle
.static var `switch`: SwitchToggleStyle
Self
is SwitchToggleStyle
.Availability 有効性
Technology
static var checkbox: CheckboxToggleStyle
{ get }
Self
is CheckboxToggleStyle
.Apply this style to a Toggle
or to a view hierarchy that contains toggles using the toggle
modifier:
Toggle("Close windows when quitting an app", isOn: $doesClose)
.toggleStyle(.checkbox)
The style produces a label that describes the purpose of the toggle and a checkbox that shows the toggle’s state. To change the toggle’s state, the user clicks the checkbox or its label:
The style aligns the trailing edge of the checkbox with the leading edge of the label, and takes as much horizontal space as it needs to fit the label, up to the amount offered by the toggle’s parent view.
This is the default style in macOS in most contexts when you don’t set a style, or when you apply the automatic
style. A Form
is a convenient way to present a collection of checkboxes with proper spacing and alignment. For guidance on using checkboxes in your user interface, see Checkboxes in the Human Interface Guidelines.
static var automatic: DefaultToggleStyle
Self
is DefaultToggleStyle
.static var button: ButtonToggleStyle
Self
is ButtonToggleStyle
.static var `switch`: SwitchToggleStyle
Self
is SwitchToggleStyle
.