AppDelegate // Add a Bool to tell whether macOS is in Dark Mode.
This commit is contained in:
parent
390ef0dbe4
commit
7e45f801d4
|
@ -299,4 +299,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
||||||
NSLog("vChewingErrorCallback: %@", strPrint)
|
NSLog("vChewingErrorCallback: %@", strPrint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@objc static func isDarkMode() -> Bool {
|
||||||
|
if #available(macOS 10.15, *) {
|
||||||
|
let appearanceDescription = NSApplication.shared.effectiveAppearance.debugDescription.lowercased()
|
||||||
|
if appearanceDescription.contains("dark") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else if #available(macOS 10.14, *) {
|
||||||
|
if let appleInterfaceStyle = UserDefaults.standard.object(forKey: "AppleInterfaceStyle") as? String {
|
||||||
|
if appleInterfaceStyle.lowercased().contains("dark") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue