Exploring NavigationStack
When SwiftUI was introduced, the basic navigation mechanism was based on a view called NavigationView
. However, NavigationView
was too simple for most apps, and NavigationStack
replaced it. In fact, Apple deprecated NavigationView
, starting with iOS 18.
Compared to NavigationView
, NavigationStack
adds a little bit of complexity to the pile, which provides us with new capabilities.
Let’s see a simple example of a NavigationStack
usage:
struct ContentView: View { var body: some View { NavigationStack { NavigationLink("Tap here to go to the next screen") { Text("Next Screen!") ...