I’m working on an app that should support both iOS and macOS (natively). I’m styling it’s navigation bar colour and need it’s title to be dark (i.e., the navigation bar should follow the light colour scheme), otherwise it’s not visible, when the system colour scheme is set to dark.
toolbarColorScheme
works for iOS, but doesn’t seem to have any effect on macOS—the title always follows the system settings.
Here’s a minimum reproducible example of code:
struct PlaygroundView: View {
var body: some View {
NavigationStack {
Text("Example")
.navigationTitle("Title")
.toolbarColorScheme(.light, for: .automatic)
.toolbarBackground(Color.yellow, for: .automatic)
.toolbarBackground(.visible, for: .automatic)
}
}
}
And here’s the result on iOS (both colour schemes—as expected) and macOS (the title colour scheme is not adjusted):
What do I do wrong? Or how else could I achieve the same effect on macOS as on iOS?
(I don’t want to paint the navigation title to a fixed custom colour, I want it to follow the system colour palette.)
I appreciate any guidance.