I have this problem while working with SwiftUI. So basically, when I press on the navigation link, it opens the screen like this:
and because of this, the whole thing below that is pushed lower. And then, when I press to the navigation link from this screen, the result is this:
so it goes even lower and creates the second "back" button.
How do I get rid of this "padding" created by the "back" button?
The way I did the navigations:
var body: some View {
NavigationView {
ZStack {
Text("Hi")
}
}
}
}
CodePudding user response:
Your issue is that you have duplicate NavigationViews
. There are two ways to solve this:
When you call the next view in your
NavigationLink
, set.navigationBarBackButtonHidden(true)
. This will disappear the extra back button.A simpler way; just delete the
NavigationView
in your second view (the linked one). That will prevent duplicate back buttons.