KEMBAR78
Navigation Link | PDF
0% found this document useful (0 votes)
8 views1 page

Navigation Link

The document describes how to create a `NavigationLink` within a `NavigationView` in SwiftUI, allowing navigation to a specified `destination`. It provides an example with a `MenuView` displaying food emojis and a `ContentView` that links to this menu. Parameters for the `NavigationLink` include `destination` and `label`, which define the view to present and its description, respectively.

Uploaded by

jon.moses2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Navigation Link

The document describes how to create a `NavigationLink` within a `NavigationView` in SwiftUI, allowing navigation to a specified `destination`. It provides an example with a `MenuView` displaying food emojis and a `ContentView` that links to this menu. Parameters for the `NavigationLink` include `destination` and `label`, which define the view to present and its description, respectively.

Uploaded by

jon.moses2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Creates an instance that presents `destination`.

A ``NavigationLink`` should be placed within a ``NavigationView`` and can


be initialized with ``NavigationLink/init(destination:label:)``. To use this
initializer, provide the `destination`, the ``View`` that is linked.
The`label` parameter can be passed in a trailing ``ViewBuilder`` closure.

```
struct MenuView: View {
var body: some View {
List {
Text("🥞")
Text("🥓")
Text("🍔")
Text("🍰")
}
.navigationTitle("Menu")
}
}

struct ContentView: View {


var body: some View {
NavigationView {
NavigationLink(destination: MenuView()) {
Text("Menu")
}
.navigationTitle("Besty's Diner")
}
}
}
```
![A gif displaying a view with the title "Betsy's Diner" and a NavigationLink
reading "Menu"; when the link is clicked, another view reading "Menu" with
4 food emoji items in a list and a back button reading "Betsy's Diner"
slides left over the current view.](nav-link-menu-ex.gif)

- Parameters
- destination: A view for the navigation link to present.
- label: A view builder that produces a label describing the destination.
Creates an instance that presents `destination` when active.
Creates an instance that presents `destination` when `selection` is set
to `tag`.
The content and behavior of the view.
The type of view representing the body of this view.

When you create a custom view, Swift infers this type from your
implementation of the required `body` property.

You might also like