1

E.g. if you navigate from View A to View B, View B will typically display a back button on the left side of the navigation bar that says "< View A" (assuming that View A's title is "View A").

When I don't have a title in View A, the back button in view B is simply "<" which is as expected, because view A has no title.

Now is there a way to make it so that if there is no title in the previous view, it should always say "< Back"?

enter image description here

pizzae
  • 2,435
  • 5
  • 21
  • 44

1 Answers1

1

You can make your own back button which can be individualized:

Put this at the top of your view:

@Environment(\.presentationMode) var presentationMode

var btnBack : some View { Button(action: {
    self.presentationMode.wrappedValue.dismiss()
}) {
    Text("< Back")
    }
}

And at at the end of your Stack in that View:

.navigationBarBackButtonHidden(true)    
.navigationBarItems(leading: btnBack)
Kuhlemann
  • 2,530
  • 3
  • 11
  • 30