In iOS 15 beta (still occurring with beta 4), navigationBarHidden(true) is no longer working if a navigation view with the .navigationViewStyle(.stack) modifier is displayed after a view that is not a NavigationView.
class SelectorHelper : ObservableObject {
@Published var show_intro : Bool = false
}
struct myApp: View {
@ObservedObject var selector_helper : SelectorHelper
var body: some View {
if selector_helper.show_intro == true {
intro(selector_helper: selector_helper)
}
else {
app_content(selector_helper: selector_helper)
}
}
}
struct intro: View {
@ObservedObject var selector_helper : SelectorHelper
var body: some View {
VStack {
Spacer()
Text("Intro")
Button(action: {
selector_helper.show_intro.toggle()
}){
Text("Show content")
}
Spacer()
}
.background(.yellow)
}
}
struct app_content: View {
@ObservedObject var selector_helper : SelectorHelper
var body: some View {
NavigationView {
VStack{
Spacer()
Text("App Content")
Button(action: {
selector_helper.show_intro.toggle()
}){
Text("Show intro")
}
Spacer()
}
.background(.green)
.navigationBarHidden(true)
}
.navigationViewStyle(.stack)
}
}