I want to remove the text from the back button, but I want to keep the icon. I have tried
let backButton = UIBarButtonItem(title: \"\", style: UIBarButtonIt
To remove from all viewcontrollers in a navigation controller stack:
subclass UINavigationController and add this:
override func show(_ vc: UIViewController, sender: Any?) {
setEmptyBackButton(vc)
super.show(vc, sender: sender)
}
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
setEmptyBackButton(viewController)
super.pushViewController(viewController, animated: animated)
}
func setEmptyBackButton(_ viewController: UIViewController) {
viewController.navigationItem.backBarButtonItem =
UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
}