let label: ToggleStyleConfiguration .Label
struct Label
Availability 有効性
Technology
struct ToggleStyleConfiguration
When you define a custom toggle style by creating a type that conforms to the Toggle
protocol, you implement the make
method. That method takes a Toggle
input that has the information you need to define the behavior and appearance of a Toggle
.
The configuration structure’s label
reflects the toggle’s content, which might be the value that you supply to the label
parameter of the init(is
initializer. Alternatively, it could be another view that SwiftUI builds from an initializer that takes a string input, like init(_:
. In either case, incorporate the label into the toggle’s view to help the user understand what the toggle does. For example, the built-in switch
style horizontally stacks the label with the control element.
The structure’s is
property provides a Binding
to the state of the toggle. Adjust the appearance of the toggle based on this value. For example, the built-in button
style fills the button’s background when the property is true
, but leaves the background empty when the property is false
. Change the value when the user performs an action that’s meant to change the toggle, like the button does when tapped or clicked by the user.
let label: ToggleStyleConfiguration .Label
struct Label
var isOn : Bool
init(ToggleStyleConfiguration )
Label
is ToggleStyleConfiguration.Label
.