1

I want to replace the < Back with <My current attempt just adds a new NavigationItem.


struct ContentView: View {
    var body: some View {
        NavigationView {
            NavigationLink(
                destination: ContentView2(),
                label: {
                    Button(action: {}, label: {
                        Text("Button")
                    }).disabled(true)
                })
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

struct ContentView2: View {
    var body: some View {
        Text("wdfokjokjokjokjwdofjk")
            .padding()
            .navigationBarItems(leading: Image(systemName: "chevron.left").foregroundColor(.green))
    }
}

enter image description here

ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
  • This has been discussed in a few different SO questions. This is the most extensive: https://stackoverflow.com/questions/56571349/custom-back-button-for-navigationviews-navigation-bar-in-swiftui – jnpdx Apr 25 '21 at 04:09

1 Answers1

1

The Back is default word for previous screen when there is no title provided there. Most simple is to use empty title, like

NavigationLink(
    destination: ContentView2(),
    label: {
        Button(action: {}, label: {
            Text("Button")
        }).disabled(true)
    })
    .navigationTitle("")      // << here - empty title !!

gives

enter image description here

Asperi
  • 228,894
  • 20
  • 464
  • 690