I am having trouble hiding the navigation bar in case of multiple navigation views. I want navigation bars to be present on first and second screen but not on the third one.
struct FirstView: View {
init() {
UINavigationBar.appearance().backgroundColor = UIColor.green
}
var body: some View {
NavigationView {
NavigationLink(destination: SecondView()) {
Text("Second View")
}.navigationBarTitle("First View")
}
}
}
// Second View
struct SecondView: View {
var body: some View {
NavigationLink(destination: ThirdView()) {
Text("Third View")
}
}
}
// Third View
struct ThirdView: View {
var body: some View {
Text("Welcome")
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
I tried hiding the navigation bar on third screen with the above code, but it doesn't work :(