0

Is there anyway to change the default Navigate-Back button color? I am using SwiftUI with NavigationView

enter image description here

John Wu
  • 111
  • 3
  • 10

2 Answers2

1

You can use the accentColor property on the NavigationView to set the back button color.

Example:

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                NavigationLink(destination: DetailView()) {
                    Text("Show Detail View")
                }.navigationBarTitle("Navigation")
            }
        }.accentColor(.red) // Replace it with required color.
    }
}

AccentColor view modifier Sets the accent color for this view and the views it contains.

Jarvis The Avenger
  • 2,750
  • 1
  • 19
  • 37
  • @John For further customisation, checkout this SO answer : https://stackoverflow.com/questions/56571349/custom-back-button-for-navigationviews-navigation-bar-in-swiftui – Jarvis The Avenger Jun 25 '20 at 03:15
0

NavigationView has two view modifiers that will probably meet your needs: foregroundColor and accentColor.

Noelle L.
  • 100
  • 6