AppDelegate // Add a Bool to tell whether macOS is in Dark Mode.
This commit is contained in:
parent
70a66a4f22
commit
a726be65b5
|
@ -299,4 +299,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
|
|||
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