0
votes

I have two views. View1 has a NavigationLink which leads to View2. However the "Back" Button to get back to View1 only says "Back" and not the title of View1.

How can I change the Buttons Text without creating a button via NavigationBarItems? Adding a Button via NavigationBarItems removes the animation when the second view shows up.

struct View1: View {
   var body: some View {
      NavigationView {
         List {
            Text("ExampleText1")
            Text("ExampleText2")
         }
         .navigationBarTitle("View1")
         .navigationBarItems(
            trailing:
               NavigationLink(destination: View2()) {
                 Image(systemName: "plus.circle").font(.system(size: 25))
                })
          }
     }
}

struct View2: View {
   var body: some View {
      List {
        Text("Example")
        Text("Example")
      }
      .navigationBarTitle("View2")
   }
}
1
Works fine with Xcode 12 / iOS 14. Try to put NavigationLink inside NavigationView, if you have lower version.Asperi
I found the Problem: "View1" was too long, even though it didn't seem like it.Kataran

1 Answers

0
votes

Solution:

"View1" was too long.