Hide navigation bar in all the views, swiftUI

Viewed 298

Currently I am working on SwiftUI project. I want to hide the build-in navbar. For this purpose I have to add these lines,

.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)

to each of view before pushing it into navigation controller in SwiftUI.

   NavigationLink(destination:
                    ForgotPasswordView()
                              .navigationBarBackButtonHidden(true)
                              .navigationBarHidden(true)
    
    ) {
            Text("Forgot Password?")
                .foregroundColor(.white)
    }

Same will be done for LoginView

NavigationLink(destination:
                        LoginView()
                                  .navigationBarBackButtonHidden(true)
                                  .navigationBarHidden(true)
        
        ) {
                Text("Login")
                    .foregroundColor(.white)
        }

So I need any generic method like we did in storyboard, hide it from root view and no child will have the navbar on top.

0 Answers
Related