0

I have a problem I have in my code. 2 navigation links that go to different views.

Does someone know how I can make the first navigation link not appear to me?

preview 1

This is my code:

preview 2

preview 3

struct ContentView: View {
@State var navigationFlag = false
var body: some View {

        


    NavigationView {
                VStack {
                    Text("First View")
                    
                    Button(action: {
                        self.navigationFlag = true
                    }, label: {
                        Text("navigate")
                    })
                    
                    NavigationLink(destination: SwiftUIView(),
                                   isActive: self.$navigationFlag,
                                   label: {
                                    EmptyView()
                                   })
    
        
    }
}
}

}

struct SwiftUIView: View {

var body: some View {
    NavigationView{
 
        NavigationLink(destination:Swift2UIView()) {
    Text("hola")
    }
    }
    

}

1 Answers1

0

In order to hide NavigationView, you can use navigationBarHidden view modifier like so:

struct ContentView: View {
    
    var body: some View {
        NavigationView {
            VStack {
                    ...
            } // set an empty string as title and then hide nav bar
            .navigationBarTitle("")
            .navigationBarHidden(true)
        }
    }
    
}
Mohammad Rahchamani
  • 5,002
  • 1
  • 26
  • 36