NavigationView
A view for presenting a stack of views that represents a visible path in a navigation hierarchy.
Declaration
struct NavigationView<Content> where Content : ViewMentioned in
Overview
Use a NavigationView to create a navigation-based app in which the user can traverse a collection of views. Users navigate to a destination view by selecting a NavigationLink that you provide. On iPadOS and macOS, the destination content appears in the next column. Other platforms push a new view onto the stack, and enable removing items from the stack with platform-specific controls, like a Back button or a swipe gesture.
[Image]
Use the init(content:) initializer to create a navigation view that directly associates navigation links and their destination views:
NavigationView {
List(model.notes) { note in
NavigationLink(note.title, destination: NoteEditor(id: note.id))
}
Text("Select a Note")
}Style a navigation view by modifying it with the navigationViewStyle(_:) view modifier. Use other modifiers, like navigationTitle(_:), on views presented by the navigation view to customize the navigation interface for the presented view.