I meet same problem.
And I do follow action to avoid it
But a little problem still live
That problem is I need use
navigationBarTitle(self.selectTitle, displayMode: .inline)can't use large title
Code Block struct AppTabNavigation: View { |
@State private var selection: Tab = .menu |
@State private var selectTitle: String = "menu" |
|
var body: some View { |
NavigationView { |
TabView(selection: $selection) { |
SmoothieMenu() |
.tabItem { |
Label("Menu", systemImage: "list.bullet") |
.accessibility(label: Text("Menu")) |
} |
.tag(Tab.menu) |
|
|
FavoriteSmoothies() |
.tabItem { |
Label("Favorites", systemImage: "heart.fill") |
.accessibility(label: Text("Favorites")) |
} |
.tag(Tab.favorites) |
|
RewardsView() |
.tabItem { |
Label("Rewards", systemImage: "seal.fill") |
.accessibility(label: Text("Rewards")) |
} |
.tag(Tab.rewards) |
|
RecipeList() |
.tabItem { |
Label("Recipes", systemImage: "book.closed.fill") |
.accessibility(label: Text("Recipes")) |
} |
.tag(Tab.recipes) |
} |
.navigationBarTitle(self.selectTitle, displayMode: .inline) |
.onChange(of: selection, perform: { value in |
print(value) |
switch value { |
case .menu: |
self.selectTitle = "menu" |
case .favorites: |
self.selectTitle = "favorite" |
case .rewards: |
self.selectTitle = "rewards" |
case .recipes: |
self.selectTitle = "recipes" |
} |
}) |
} |
} |
} |