Use new currentDrawing() for NSAppearance

This commit is contained in:
1024jp 2021-09-20 22:22:07 +09:00
parent 498406bce6
commit 74d6a38ad8

View File

@ -41,12 +41,12 @@ extension NSColor {
/// - Returns: A CGColor instance.
func cgColor(for appearance: NSAppearance) -> CGColor {
guard NSAppearance.current != appearance else { return self.cgColor }
guard NSAppearance.currentDrawing() != appearance else { return self.cgColor }
let currentAppearance = NSAppearance.current
NSAppearance.current = appearance
let cgColor = self.cgColor
NSAppearance.current = currentAppearance
var cgColor: CGColor = .clear
appearance.performAsCurrentDrawingAppearance {
cgColor = self.cgColor
}
return cgColor
}