I have a tabview with three SwiftUIViews (HomeView, FavoritesView and ContactsView) each of these views look like this Home View below.
struct HomeView: View {
var body: some View {
VStack {
Image(systemName: "house.fill")
Text("This is the Home View")
}
}
}
My content view looks like this:
struct ContentView: View {
var body: some View {
NavigationView {
TabView {
HomeView()
.tabItem {
Label("Home", systemImage: "house")
.navigationBarTitle("Home")
}
FavoritesView()
.tabItem {
Label("Favorites", systemImage: "star")
.navigationBarTitle("Favorites")
}
ContactsView()
.tabItem {
Label("Contacts", systemImage: "person")
.navigationBarTitle("Contacts")
}
}
}
}
}
But when I run the app each tab get the same "Home" title for the navigation title.
How can I update the navigation title with the correct tab (without adding a navigation View in each SwiftUI Views) I believe we should be able to achieve this with only one nav view? Right???