User interface style for NSToolbar on Catalyst

Hi, in my app the user can choose between a light and a dark appearance.

This is done by setting the overrideUserInterfaceStyle of the window.

On macOS (Catalyst) the app uses an NSToolbar, which always appears in the mode set for the system, regardless what ist set for the overrideUserInterfaceStyle of the window (see screenshot).

Since this is not a good visual impression, I would like to know how I can set light/dark mode for the NSToolbar too.

Answered by iosdev98278 in 710521022

This can be done by adding an macOS plugin which has access to the whole AppKit API.  Then you can set the desired appearance there at runtime, for example:

NSApplication.shared.appearance = NSAppearance(named: .darkAqua)

For more information please see this StackOverflow question: How to set dark mode for NSToolbar in macOS Catalyst app?

Did you ever figure this out?

Accepted Answer

This can be done by adding an macOS plugin which has access to the whole AppKit API.  Then you can set the desired appearance there at runtime, for example:

NSApplication.shared.appearance = NSAppearance(named: .darkAqua)

For more information please see this StackOverflow question: How to set dark mode for NSToolbar in macOS Catalyst app?

User interface style for NSToolbar on Catalyst
 
 
Q