Search code examples
xcodeswiftmacoscocoansuserdefaults

Disable dark mode for mac OSX App in Swift


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.


Solution

  • 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)