swiftuikitmac-catalysttintcolormacos-big-sur

Set tintColor in macCatalyst


In macOS Big Sur a multicolor accent color is allowed, no longer overwriting an app’s custom tint color (in theory).

preferences

This can be seen in a few system apps:

podcasts music

(images from this tweet)

However setting the tintColor property of a view, a window, or even UIView.appearance() still results in the default blue in macCatalyst. Not even setting onTintColor of a checkbox (UISwitch) has any effect.

error

Is this a bug or is there a correct way to do this?


Solution

  • You do it the same way you set tint color for a Watch app:

    1. Open the app’s asset catalog.
    2. Select the Editor > Add New Asset > Color Set menu item to add a new color set to the asset catalog.
    3. In the app’s Build Settings, set the “Global Accent Color Name” to your color set’s name.

    Apple’s WatchKit instructions are here, but it’s actually the same for all platforms: https://developer.apple.com/documentation/watchkit/setting_the_app_s_tint_color