Swift UI元素在12和13个iOS中具有不同的颜色
我的屏幕上有一些UI(UIButton、UISegmentControl等),我通过逻辑编程为它们设置颜色。但它们的显示方式不同。在IOS 12上我有默认的蓝色,在IOS 13上一切正常 我用于更改段控制的颜色:Swift UI元素在12和13个iOS中具有不同的颜色,swift,ios13,ios12,Swift,Ios13,Ios12,我的屏幕上有一些UI(UIButton、UISegmentControl等),我通过逻辑编程为它们设置颜色。但它们的显示方式不同。在IOS 12上我有默认的蓝色,在IOS 13上一切正常 我用于更改段控制的颜色: func changeTitleTextColor(normalColor: UIColor, selectedColor: UIColor) { let normalTextColor = [NSAttributedString.Key.foregroundColor: no
func changeTitleTextColor(normalColor: UIColor, selectedColor: UIColor) {
let normalTextColor = [NSAttributedString.Key.foregroundColor: normalColor]
let selectedTextColor = [NSAttributedString.Key.foregroundColor: selectedColor]
self.setTitleTextAttributes(normalTextColor, for: .normal)
self.setTitleTextAttributes(selectedTextColor, for: .selected)
}
对于UIButton,我只使用:
func customizeBy(checked: Bool) {
backgroundColor = checked ? Colors.MattGreen : .white
tintColor = checked ? .white : .clear
borderColor = checked ? .clear : Colors.PlaceholderColor
}
其颜色为“我的自定义结构”返回的UIColor:
struct Colors {
static let MattBlack = UIColor(named: "MattBlack")!
}
有什么不对劲 什么是
Colors
类,它不是UIKit或swiftUI类。它是我的自定义类,带有来自资产的颜色。