Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of back button on NavigationView

Tags:

When you click on the button it takes you to a new view and puts a back button in the top left. I can't figure out what property controls the color of the back button. I tried adding an accentColor and foregroundColor but they only edit the items inside the view.

var body: some View {     NavigationView {         NavigationLink(destination: ResetPasswordView()) {             Text("Reset Password")             .foregroundColor(Color(red: 0, green: 116 / 255, blue: 217 / 255))             .padding()         }     } } 
like image 685
Michael St Clair Avatar asked Jun 11 '19 00:06

Michael St Clair


People also ask

How do I change the color of the navigation bar in Swift?

navigationBar. barTintColor = UIColor. newBlueColor() and of course this just changes the colour of the navigation bar of the view controller that the code is within.


Video Answer


1 Answers

You can use the accentColor property on the NavigationView to set the back button color, like in this example:

var body: some View {     NavigationView {         List(1..<13) { item in             NavigationLink(destination: Text("\(item) x 8 = \(item*8)")) {                 Text(String(item))             }         }.navigationBarTitle("Table of 8")     }.accentColor(.black) // <- note that it's added here and not on the List like navigationBarTitle() } 
like image 83
turingtested Avatar answered Sep 21 '22 14:09

turingtested