Adding navigation to our ContentView

Head on over to ContentView.swift, identify the following lines of code, and then add the highlighted section:

var body: some View {    NavigationView {        VStack {            //Existing Logic...        }        .navigationBarTitle(Text("My Favourite Recipes"))    }}

We'll start by wrapping a NavigationView around our VStack and also by adding a navigationBarTitle modifier to give our NavigationView a title.

Resume the automatic preview window to see how this looks, and you should now see your title sitting nicely above the segmented picker.

This is all well and good, but we still need to hook up each row to our new RecipeDetailView(). Surprisingly enough, this is done by adding one simple wrapper around our RecipeDetailView() iteration ...

Get Learn SwiftUI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.