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

3.6k views Asked by At

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,

1

There are 1 answers

1
Asperi On BEST ANSWER

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("")
    }
}