【发布时间】:2020-11-25 21:37:02
【问题描述】:
我在 SwiftUI 中使用 SegmentedPicker 样式的 Picker。
我正在尝试更改选择器的颜色,并在 stackoverflow 中找到了此代码。 How to change selected segment color in SwiftUI Segmented Picker
init() {
UISegmentedControl.appearance().selectedSegmentTintColor? = .blue
UISegmentedControl.appearance().setTitleTextAttributes([.foregroundColor: UIColor.white], for: .selected)
UISegmentedControl.appearance().setTitleTextAttributes([.foregroundColor: UIColor.blue], for: .normal)
}
但是弹出一个错误说“从初始化程序返回而不初始化所有存储的属性”
我该怎么做才能使错误消失:(
【问题讨论】:
标签: ios swift swiftui swiftui-list