【问题标题】:How to create segmented buttons in SwiftUI?如何在 SwiftUI 中创建分段按钮?
【发布时间】:2020-04-28 11:57:55
【问题描述】:

如何在macOS swiftui中实现如下按钮外观?

【问题讨论】:

    标签: swift macos swiftui


    【解决方案1】:

    您使用PickerSegmentedPickerStyle

    Picker(selection: $selectedOption, label: Text(""), content: {
        Text("+")
        Text("-")
    }).pickerStyle(SegmentedPickerStyle())
    

    $selectedOption 是一个绑定:

    @State var selectedOption: Int?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-11
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 2021-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多