Dark mode Mac OS

703 views Asked by At

I received this error from Apple at the time of publication of my application. how can I solve this problem? We found that when Dark Mode is enabled, the menu bar extra icons aren't visible. I can not find anything online to define Dark mode...

enter image description here enter image description here enter image description here

1

There are 1 answers

0
DarkDust On BEST ANSWER

I see the term cache in your code and taking some guesses:

It looks like you are loading the images, then manipulating them and storing the manipulated images for later use. There are a number of things you need to take care of:

First of all, make sure the current appearance is set correctly when you do your image loading/manipulation. Outside of drawRect: and a few other methods, you always need to do a dance similar to this:

NSAppearance * savedAppearance = [NSAppearance currentAppearance];
[NSAppearance setCurrentAppearance:someView.effectiveAppearance];

// Do your image/color/drawing stuff.

[NSAppearance setCurrentAppearance:savedAppearance];

Be aware that the appearance is "scoped" to a specific view! You can have different appearances in the same view hierarchy.

You need to either override viewDidChangeEffectiveAppearance of your NSView or KVObserve the effectiveAppearance of a view to get notified about appearance changes and react accordingly (recreate your icons).