When I include a Page View as written by Apple in a Navigation View with a hidden Navigation Bar Title, swiping the page makes the title appear.
struct ContentView: View {
var body: some View {
NavigationView {
PageView(pages: [Text("Foo"), Text("Bar")])
.navigationBarTitle("Title")
.navigationBarHidden(true)
}
}
}
I tried adding a state variable that sets the navigationBarHidden
Bool to true
using a button, to no avail. It seems like the connection between the navigationBarHidden
property and the UI breaks when the Page View flips the page.
I was able to hack something that worked by forcing the view with the navigation title to redraw by putting in both in the if navigationBarHidden
and else
blocks and triggering a .onAppear { isNavigationBarHidden = true }
in the else
block, but that stinks.