Forum Xamarin.Mac

Any ideas on how to detect the status bar color

Hi,

Previously to decide the icon color in the status bar we just checked the dark/light theme like so:

NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle");

Well now in Big Sur the status bar color is determined by the desktop wallpaper so the old implementation does not work anymore. By Googling I have found all kind of hacks from detecting pixel colors to checking appearance name of menu button
new NSStatusBarButton().EffectiveAppearance.Name
but all of these seem to be hacks that don't work reliably. Main issue is that now user can have different wallpaper for every single display. This means that there has to be some kind of automatic way to switch the icon based on the status bar color.

Has any one found any solution for this issue? Any tips are highly appreciated.

Thanks

Posts

  • VRahikkaVRahikka Member ✭✭
    edited November 2020

    It seems that I have been doing it all wrong all along. Just found out that when you set the icon in Assets.xcassets file there are different tabs for light and dark themes. I was only using Any Appearance version. Setting icons for Light and Dark theme solves my issue and icon is change automatically.

Sign In or Register to comment.