Reputation: 3977
I know I can set the navigation bar back buttons's title with:
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)
However there are parts of my app where I want to set it back to the default text "Back" (that will also use localization). How would I go about doing this?
Upvotes: 1
Views: 464
Reputation: 149
This little hack seemed to work when I place it immediately after my call to pushViewController
in the parent view controller.
However, my testing on an iPad Pro simulator reveals that it not only tries to display the abbreviated text, but the back button even covers up any UIButtonBarItem
that is intended to appear on the right side.
let backButtonItem = UIBarButtonItem()
backButtonItem.title = "A button title which is much too long to be displayed in the navigation bar, so that iOS will replace this text with localized 'Back' button text."
navigationItem.backBarButtonItem = backButtonItem
Upvotes: 1