Is it possible to hide/remove a NavigationBar but keep the back button visible?
I have tried hiding the whole navigation bar and adding a custom back button using a NavigationLink but then I get a back button on my first view (ProductList) when pressing back which wasn't there before.
If I have to create a custom back button is there a different way than NavigationLink like I am using in Tab1View to eliminate a back button appearing in ProductList when navigating back?
This is the first view that uses a NavigationLink to a TabBar:
struct ProductList: View {
ScrollView{
VStack{
ForEach(matchedItems) { item in
NavigationLink(destination: TabView(product: item)){
Text("MoveToTabView")
}
}
}
}
}
}
I am then using a TabBar where I am hiding the NavigationBar:
struct TabView: View {
var product: ProductModel
var body: some View {
TabView {
// TAB 1
Tab1View(product: product).tabItem {
Text(product.detailTabNames[0])
}
.navigationBarTitle("")
.navigationBarHidden(true)
// TAB 2
Tab2View(product: product).tabItem {
Text(product.detailTabNames[1])
}
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
}
And finally the final View from the Tabbar where I am adding my own custom back button:
struct Tab1View: View {
var product: ProductModel
var body: some View {
ZStack(alignment: .topLeading) {
Text("Tab1View")
NavigationLink(destination: ProductList()){
Image(systemName: "chevron.backward")
}
}
}
}