Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift UI元素在12和13个iOS中具有不同的颜色_Swift_Ios13_Ios12 - Fatal编程技术网

Swift UI元素在12和13个iOS中具有不同的颜色

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

我的屏幕上有一些UI(UIButton、UISegmentControl等),我通过逻辑编程为它们设置颜色。但它们的显示方式不同。在IOS 12上我有默认的蓝色,在IOS 13上一切正常

我用于更改段控制的颜色:

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类。它是我的自定义类,带有来自资产的颜色。