Generic Structure

Toggle

A control that toggles between on and off states.

Declaration

struct Toggle<Label> where Label : View

Overview

The appearance and interaction of Toggle is determined at runtime and can be customized. Toggle uses the ToggleStyle provided by its environment to define its appearance and interaction. Each platform provides a default style that reflects the platform style, but providing a new style will redefine all Toggle instances within that environment.

Topics

Creating a Toggle

init(ToggleStyleConfiguration)
init<S>(S, isOn: Binding<Bool>)
init(isOn: Binding<Bool>, label: () -> Label)

Creates an instance that displays state based on isOn.

Styling a Toggle

Applying Standard Modifiers

View Modifiers

Configure this view and the views it contains by applying standard modifiers.

Relationships

Conforms To

See Also

Value Selectors

struct Picker

A control for selecting from a set of mutually exclusive values.

struct DatePicker

A control for selecting an absolute date.

struct Slider

A control for selecting a value from a bounded linear range of values.

struct Stepper

A control used to perform semantic increment and decrement actions.