Navigation Bar Items Leading is not working

The trailing navigation bar items are working but the leading ones just do not show up at all. What is the solution?
Answered by OOPer in 665027022
Seems like working:
Code Block
struct ContentView: View {
var body: some View {
NavigationView {
MainView()
.navigationBarItems(leading: Button(action: {}, label: {Image(systemName: "plus")}))
}
}
}
struct MainView: View {
var body: some View {
VStack {
NavigationLink(
"To second",
destination: SecondView()
.navigationBarItems(leading: Text("Leading"))
)
Text("MainView")
}
}
}
struct SecondView: View {
var body: some View {
Text("SecondView")
}
}


What is the solution?

When you want some solution about the code which does not run as expected, you should better include the issue-reproducible code.
Simplified would be welcome, but please include all the information required to run and test it.
Accepted Answer
Seems like working:
Code Block
struct ContentView: View {
var body: some View {
NavigationView {
MainView()
.navigationBarItems(leading: Button(action: {}, label: {Image(systemName: "plus")}))
}
}
}
struct MainView: View {
var body: some View {
VStack {
NavigationLink(
"To second",
destination: SecondView()
.navigationBarItems(leading: Text("Leading"))
)
Text("MainView")
}
}
}
struct SecondView: View {
var body: some View {
Text("SecondView")
}
}


What is the solution?

When you want some solution about the code which does not run as expected, you should better include the issue-reproducible code.
Simplified would be welcome, but please include all the information required to run and test it.
Navigation Bar Items Leading is not working
 
 
Q