Is it possible to disable the dark mode for the mac app?
I only want it to show the default style of my app, even if the user uses dark mode on his mac.
I am using a popover.
Tried to use this: self.popover.appearance = NSAppearanceNameAqua
but it tells me: cannot assign value of type String to type NSApperance.
To control an interface style for an entire app, you simply set UIUserInterfaceStyle (Appearance) key in your Info. plist file. You can assign it to either Light or Dark value to force a light and dark user interface style. Set Appearance (UIUserInterfaceStyle) key to Light will disable dark mode for an entire app.
Dark mode can also be quickly enabled from Control Center. Click the switch icon in the menu bar and click Display, then choose Dark Mode to switch the feature on and off.
Tap the hamburger menu in the top-right (Android) or bottom-right (iOS) corner, scroll down and select Settings & Privacy > Dark Mode. You can then turn it on or off, or make the app dependent on your phone's system-wide theme.
In the menu, find Settings and tap on it. Tap on General. Find the Theme option, tap it, and you will get to choose between Light and Dark. There is a third option that will set the theme in accordance with your device's global dark mode settings.
You'll need initialize the name first:
popover.appearance = NSAppearance(named: NSAppearanceNameAqua)
You were close.
Edit for Swift 4.1:
popover?.appearance = NSAppearance(named: NSAppearance.Name.aqua)
You can disable support for dark mode in the Info.plist of your app:
Opt Out of Dark Mode
Apps linked against macOS 10.14 or later should support both light and dark appearances. If you build your app against an earlier SDK, you can still enable Dark Mode support by including the
NSRequiresAquaSystemAppearance
key (with a value offalse
) in your app'sInfo.plis
file. Do so only if your app's appearance looks correct when running in macOS 10.14 and later with Dark Mode enabled.If you need extra time to work on your app's Dark Mode support, you can temporarily opt out by including the
NSRequiresAquaSystemAppearance
key (with a value oftrue
) in your app’sInfo.plist
file. Setting this key to true causes the system to ignore the user's preference and always apply a light appearance to your app.
Source: https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_app
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With