0

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")
   }
}
2
  • Works fine with Xcode 12 / iOS 14. Try to put NavigationLink inside NavigationView, if you have lower version. Commented Aug 15, 2020 at 15:15
  • I found the Problem: "View1" was too long, even though it didn't seem like it. Commented Aug 29, 2020 at 12:24

1 Answer 1

0

Solution:

"View1" was too long.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.