swiftuinavigationbarswiftui-navigationlinknavigationlink

SwiftUi - hide "Back" button and navigation bar (appears for a fraction of second)


I'm using this code to hide a navigation bar and Back button but when the view is loaded i still can see the back button for a fraction of second and then it disappears. Is there any way to prevent it from being shown?

var body: some View {
    NavigationView {
        NavigationLink(destination: DeferView { WeekView(journey: self.launcher.completeJourney!) }, isActive: self.$launcher.readyJourney ) { EmptyView () }
        .navigationBarHidden(true)
        .navigationBarTitle("")
    }
}

Thank you in advance,


Solution

  • Add the same modifiers also for link destination,

    var body: some View {
        NavigationView {
            NavigationLink(destination: DeferView { WeekView(journey: self.launcher.completeJourney!) }
                                        .navigationBarHidden(true)   // here !!
                                        .navigationBarTitle("")      // here !!
    
                  , isActive: self.$launcher.readyJourney ) { EmptyView () }
            .navigationBarHidden(true)
            .navigationBarTitle("")
        }
    }