For the reason outlined in the answer outlined in this question SwiftUI TabView brightness views vertical location the menu structure for my app is NavigationView
-> TabView
-> sub view with varying navigation titles.
The problem is that .navigationTitle
gives one navigation title for the whole TabView rather than one for each sub view. How do I have multiple navigation titles with TabView
, one for each sub-view?
struct ContentView: View {
var body: some View {
NavigationView {
TabView {
Text("Hello")
.navigationTitle("Title One")
.tabItem {
Image(systemName: "square.stack")
}
Text("Hello Again")
.navigationTitle("Title Two")
.tabItem {
Image(systemName: "checkmark.square")
}
}
}
}
}