The screen transitions with NavigationLink. I want to return to the first screen by clicking the button on the third screen. How do you do it?
The following code returns from the third screen to the second screen.
struct FirstView: View {
var body: some View {
VStack {
NavigationView {
NavigationLink(
destination: SecondView()
) {
Text("next")
}
}
}
}
}
struct ThirdView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var body: some View {
VStack {
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}) {
Text("next")
}
}
.navigationBarTitle("Third", displayMode: .inline)
}
}