Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Modify swiftui back button

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?

extra button appear

 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)
        }
    }
  }
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Hide default one explicitly, like

List {
    Text("Fish")
    Text("Octopus")
    Text("Shark")
}
.navigationBarBackButtonHidden(true)   // << here !!
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading