I am trying to modify swiftui back button by giving it different word and color. But an extra back button still appear even i did not include it.
How can i get rid of it and make my cancel button does the navigate back like the original back button?
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: SeaView()) {
Text("SeaView")
}
}
}
}
struct SeaView: View {
var body: some View {
List {
Text("Fish")
Text("Octopus")
Text("Shark")
}
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button("Cancel") {
}.foregroundColor(Color.red)
}
}
}
}
>Solution :
Hide default one explicitly, like
List {
Text("Fish")
Text("Octopus")
Text("Shark")
}
.navigationBarBackButtonHidden(true) // << here !!