Setting tint colour in macOS SwiftUI app
It did some digging today and it appears that on macOS the only way to override the tint colour, which can be set in the assets catalogue, doesn’t work for some UI elements, like sidebars. Every blog I found suggests setting the .tint()
property on the root view of the application:
var body: some Scene {
WindowGroup {
ContentView()
.tint(Color.purple)
}
}
Actually, the above doesn’t work and interface elements like selection will still be system default.
It’s possible to change the colour in the assets catalogue, but it only works statically and can’t be changed during runtime.
I wanted to let my users modify the tint colour, but knowing it’s not technically possible, I will probably have to switch to the default system choice. At least it can be changed in macOS preferences.