Toggle

作者: 水之飞亦 | 来源:发表于2020-03-28 21:16 被阅读0次

    Creating a Toggle

    init(ToggleStyleConfiguration)

    Available when Label is ToggleStyleConfiguration.Label.

    init(LocalizedStringKey, isOn: Binding<Bool>)

    Available when Label is Text.

    init<S>(S, isOn: Binding<Bool>)

    Available when Label is Text.

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

    Creates an instance that displays state based on isOn.

    Styling a Toggle

    struct DefaultToggleStyle

    struct SwitchToggleStyle

    struct CheckboxToggleStyle

    protocol ToggleStyle

    A specification for the appearance and interaction of a Toggle.

    Toggle.init(isOn: $isOn) {
         Button.init("button") {
             print("button")
         }
    }
    Toggle.init(isOn: $isOn) {
         Text("开启定位")
             .foregroundColor(Color.purple)
    }
    Toggle.init("允许读取通讯录", isOn: $isOn)
         .toggleStyle(DefaultToggleStyle())
    

    相关文章

      网友评论

          本文标题:Toggle

          本文链接:https://www.haomeiwen.com/subject/nuvjuhtx.html