How to customize navigation bar tint color and text color in SwiftUI?

I want to customize navigation bar tint color and text color, but can't figure out how tio do this in SwiftUI?


Replies

Bob I saw on social media to do it but it's not standard....it maybe has been left out of beta 1 and 2

You can set the accent color with modifier .accentColor(Color.red) it also good idea to add the color you actually going to use in your assets catalog and use it by name, in my case .accentColor(Color("Salmon Gal")).

It doesn't work. It change NavigationButton color, but not a navBar or text color:


import SwiftUI

struct TaskList : View {
    var body: some View {
        List(0 ..< 5) { item in
            NavigationButton(destination: TaskEditor()) {
                Text("Hello World!")
            }
        }
        .navigationBarTitle(Text("Tasks"), displayMode: .inline)
        .navigationBarItems(trailing: NavigationButton(destination: TaskEditor()) {
                Image(systemName: "plus")
        })
        .accentColor(Color("Light Green"))
    }
}


#if DEBUG
struct TaskList_Previews : PreviewProvider {
    static var previews: some View {
        NavigationView {
            TaskList()
        }
    }
}
#endif