How do I remove text from navigation back button?

I'm navigating from a master view that has a list of cells to a details view that has the details of the tapped cell.

I want to remove the text on the back button of the details view. I don't want it to show the navigation bar title of the master view. like we used to do in UIKit. how?

To hide the back button:

.navigationBarBackButtonHidden(true)


struct SampleDetails: View {
    var body: some View {
        List {
            Text("sample code")
        }
        .navigationBarBackButtonHidden(true)
    }
  }


where SampleDetails is the view you navigate to.


If you want a back button with just a plain "<":

https://stackoverflow.com/questions/56571349/custom-back-button-for-navigationviews-navigation-bar-in-swiftui


struct SampleDetails: View {
    @Environment(\.presentationMode) var presentationMode: Binding
  
    var btnBack : some View { Button(action: {
        self.presentationMode.wrappedValue.dismiss()
    }) {
        HStack {
            Image("ic_back") // set image here
                .aspectRatio(contentMode: .fit)
                .foregroundColor(.white)
            Text("<")
        }
        }
    }
  
    var body: some View {
        List {
            Text("sample code")
        }
        .navigationBarBackButtonHidden(true)
        .navigationBarItems(leading: btnBack)
    }
}

if you just want to show "<" without the text:

.navigationTitle("")

How do I remove text from navigation back button?
 
 
Q