Leo*_*bus 14
您可以使用 UIColor 方法func resolvedColor(with traitCollection: UITraitCollection) -> UIColor并选择所需的特征集合:
extension UIColor {
var dark: UIColor { resolvedColor(with: .init(userInterfaceStyle: .dark)) }
var light: UIColor { resolvedColor(with: .init(userInterfaceStyle: .light)) }
}
Run Code Online (Sandbox Code Playgroud)
let systemPurple = UIColor.systemPurple // r 0,686 g 0,322 b 0,871 a 1,0
systemPurple.dark // r 0,749 g 0,353 b 0,949 a 1,0
systemPurple.light // r 0,686 g 0,322 b 0,871 a 1,0
Run Code Online (Sandbox Code Playgroud)