I should note that even stranger behavior arises when adding a third tab. Here's a new version of the file:
struct ContentView: View {
var body: some View {
TabView {
Tab("Tab 1", systemImage: "document") {
NavigationStack {
VStack {
Text("Tab 1")
NavigationLink("Load Detail") {
VStack {
Text("Detail View")
}.toolbarVisibility(.hidden, for: .bottomBar, .tabBar)
}
}
}
}
Tab("Tab 2", systemImage: "map") {
NavigationStack {
VStack {
Text("Tab 2")
}
}
}
Tab("Tab 3", systemImage: "heart") {
VStack {
Text("Toolbar entirely hidden")
}.toolbarVisibility(.hidden, for: .bottomBar, .tabBar)
}
}.tabViewBottomAccessory {
Button("Action") {}
}
}
}
This third tab contains a no-navigation stack view that simply hides the tab bar ( admittedly, this is somewhat nonsensical, but just showing the issue ). Upon clicking on this third tab, the tab bar disappears momentarily, then returns. When you navigate to another tab, then the tab bar disappears permanently. If you follow this sequence of steps:
Open app
Navigate to third tab
Observe tab bar disappear
Observe tab bar reappear
Navigate to first tab
Observe tab bar disappear
Click on detail link
Observe tab bar remains hidden
Click on "back"
Observe tab bar reappear
This seems to indicate there might be two bugs at play:
Tab bar / bottom bar visibility should affect the tab view bottom accessory, and does not
When changing tab bar visibility from a contained view, the setting is not correctly respected across tabs
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: