RGB颜色
/// 动态颜色
/// - Parameter lightColor: lightMode Color
/// - Parameter darkColor: darkMode Color
static func dy_color(light: UIColor, dark: UIColor) -> UIColor {
var color: UIColor = light
if #available(iOS 13.0, *) {
color = UIColor.init { (trainCollection: UITraitCollection) -> UIColor in
if trainCollection.userInterfaceStyle == UIUserInterfaceStyle.dark {
// 黑暗模式
return dark
}else {
// 其他模式
return light
}
}
}
return color
}
16进制颜色
/// 动态颜色(16进制)
/// - Parameter lightColor: lightMode Color
/// - Parameter darkColor: darkMode Color
static func dy_color(light: Int, dark: Int) -> UIColor {
var color = UIColor.gl_hex(hex: light)
if #available(iOS 13.0, *) {
color = UIColor.init { (trainCollection: UITraitCollection) -> UIColor in
if trainCollection.userInterfaceStyle == UIUserInterfaceStyle.dark {
// 黑暗模式
return UIColor.gl_hex(hex: dark)
}else {
// 其他模式
return UIColor.gl_hex(hex: light)
}
}
}
return color
}
网友评论