My problem is as I described it in the title.
I have tried the code below but it's adding a nav bar instead of pushing back the view and returning directly to RootView
.
Thank you for your help :)
import SwiftUI
struct RootView: View {
var body: some View {
NavigationView{
NavigationLink(
destination: View1(),
label: {
Text("Navigate to view1")
})
}
}
}
struct View1: View {
var body: some View {
NavigationLink(
destination: View2(),
label: {
Text("Navigateto view2")
}) }
}
struct View2: View {
var body: some View {
NavigationLink(
destination: RootView(),
label: {
Text("Navigateto Root")
})
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
RootView()
}
}