Fix label color foreground color

This commit is contained in:
Jackson Harper
2023-02-08 18:50:58 +08:00
parent c5cb5d9514
commit 35a2e91fb8

View File

@ -87,13 +87,19 @@ public extension Color {
}
#endif
let colorR = Double(Int(components[0] * 255)) * 0.2126
let colorG = Double(Int(components[1] * 255)) * 0.7152
let colorB = Double(Int(components[2] * 255)) * 0.0722
let colorR = channelColor(components[0]) * 0.2126
let colorG = channelColor(components[1]) * 0.7152
let colorB = channelColor(components[2]) * 0.0722
return Float(colorR + colorG + colorB)
}
private func channelColor(_ channel: CGFloat) -> Double {
channel <= 0.03928
? channel / 12.92
: pow((channel + 0.055) / 1.055, 2.4)
}
static var isDarkMode: Bool {
#if os(iOS)
UITraitCollection.current.userInterfaceStyle == .dark