How can i prevent that: and that: I mean the space between the navigationbackbutton and the List and the Sports back button. The regions back button can stay. The code looks like this: home.swift:
struct Home: View {
var body: some View {
NavigationView {
List {
NavigationLink(
destination:example1(),
label: {
Text("to example1")
}
)
}.navigationBarTitle(Text("home"))
}}
example1.swift:
struct example1: View {
var body: some View {
NavigationView {
List {
NavigationLink(
destination:example2(),
label: {
Text("to example2")
}
)
}.navigationBarTitle(Text("example1"))
}}
example2.swift:
struct example2: View {
var body: some View {
Text("hello world")
}
CodePudding user response:
The problem is that you have nested NavigationView
s. You only want one, at the top level of whatever you need navigating.
All you need to do is remove the NavigationView
in example1
, like so:
struct example1: View {
var body: some View {
List {
NavigationLink(
destination: example2(),
label: {
Text("to example2")
}
)
}.navigationBarTitle(Text("example1"))
}
}