When I casually research and use it, how do I write it when I try to use it again ... Since it is often the case, I will record it as a memorandum.
extension
extension UITraitCollection {
public static var isDarkMode: Bool {
if #available(iOS 13, *), current.userInterfaceStyle == .dark {
return true
}
return false
}
}
if UITraitCollection.isDarkMode {
//If true
}else{
//If false
}
extension
extension UIColor {
static func rgb(red: CGFloat,green: CGFloat,blue: CGFloat,alpha: CGFloat) -> UIColor {
return self.init(red: red / 255, green: green / 255, blue: blue / 255,alpha: alpha)
}
}
let color:UIColor = .rgb(red: 10, green: 10, blue: 10, alpha: 1.0)