How to detect the "Accessibility Reduce Transparency" In macOS (Objective-C)?

170 views Asked by At

By default, macOS11.0 Big Sur set the "reduce transparency" to true on Accessibility. That makes the light status menu almost the same as the dark one, thus make the setting of my app's status menubar icon becomes a challenge.

On iOS, a simple UIKit function could do the trick:

if (UIAccessibilityIsReduceTransparencyEnabled()){
    //use the icon for dark mode although we are in light mode now
}

But there is no way to implement it on macOS although the Apple documentation indicated the Availability is iOS 8.0+ and macOS Catalyst 13.0+

Any ideas? Thank you!

1

There are 1 answers

0
Alex Beals On

You can use the defaults read com.apple.universalaccess reduceTransparency command. It's 1 if it's enabled, and 0 if it's not. In Objective-C that looks something like this:

- (BOOL)isTransparencyEnabled {
  Boolean keyExists = false;
  Boolean transparencyEnabled = CFPreferencesGetAppBooleanValue( CFSTR("reduceTransparency"), CFSTR("com.apple.universalaccess"), &keyExists);
  return keyExists && transparencyEnabled;
}