Learn Courses My Dashboard

Navigation Bar Back Button - change colour

Hi there,

I’m trying to change the colour of the back button in a Navigation View. So when you’ve clicked through to a navigation link, and it says back in the navigation bar - I want to change the colour of this. I’ve managed to change the navigation bar itself to be blue but the default colour for the back seems to be also blue and I want to change this to white. I’ve tried Dr Google but so far had no success figuring it out. I’m using Swift UI.

Thanks

Chris

There is no way to do this in SwiftUI; you need to use UIKit methods to achieve it.

For instance, this will make the back button purple:

struct ColorNav: View {
    
    init() {
        UINavigationBar.appearance().tintColor = .purple
    }
    
    var body: some View {
        NavigationView {
            NavigationLink("Test", destination: Text("Testing screen"))
        }
    }
}