Home > Back-end >  How to opt out from dark mode on a MacOS app?
How to opt out from dark mode on a MacOS app?

Time:12-04

I want to set my swift app to always be in Light mode (to opposite to auto dark/light). All articles I could find on internet are for iOS and don't seem to work - being UIUserInterfaceStyle to Light, UIApplication.shared.windows.first?.overrideUserInterfaceStyle to .light..., or even looking for an option in the Interface Builder.
I am not using a viewController class but have my code directly in AppDelegate, hence no viewDidLoad.
What's the way to force light mode ?

CodePudding user response:

In applicationDidFinishLaunching, add the following line:

window.appearance = NSAppearance(named: .vibrantLight)
  • Related