fix: connection panel dark mode issue[beta]

This commit is contained in:
yicheng 2023-07-18 13:34:01 +08:00
parent 740f84c99b
commit 2268b132a2
1 changed files with 19 additions and 1 deletions

View File

@ -22,10 +22,28 @@ class ConnectionDetailInfoView: NSView {
init() {
super.init(frame: .zero)
wantsLayer = true
layer?.backgroundColor = NSColor.white.cgColor
updateColor()
setupSubviews()
}
override func viewDidChangeEffectiveAppearance() {
super.viewDidChangeEffectiveAppearance()
updateColor()
}
func updateColor() {
if #available(macOS 11.0, *) {
effectiveAppearance.performAsCurrentDrawingAppearance {
layer?.backgroundColor = NSColor.controlColor.cgColor
}
} else {
let pervious = NSAppearance.current
NSAppearance.current = effectiveAppearance
layer?.backgroundColor = NSColor.controlColor.cgColor
NSAppearance.current = pervious
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}