In my example code, the navigation bar should be hidden in the second view, but it isn't.
How it behaves?
After tapping on the push button on the first view (0), it suddenly disappears, and it's hidden during the push animation. When the animation stops, the navigation bar suddenly appears (but it shouldn't be visible on the second view (1)). When I tap push once again (view (1) -> view (2)), the navigation bar is visible during the animation, but after the animation, it disappears! (but it should be visible) Does anybody know how to manage showing/hiding navigation bar properly in SwiftUI?
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
CountView(count: 0)
}
}
}
struct CountView: View {
init(count: Int) {
self.count = count
}
let count: Int
var body: some View {
VStack {
Text("\(count)")
NavigationLink(destination: CountView(count: count + 1)) {
Text("Push")
}
}
.navigationBarHidden(count == 1)
.navigationBarTitle("\(count)", displayMode: .inline)
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View { ContentView() }
}
#endif