11/6/2018 The lastest way
It is the best way to hide left back title of the navigation bar so far.
class YGCustomNavigationVC: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
}
}
extension YGCustomNaviVC:UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
let item = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
viewController.navigationItem.backBarButtonItem = item
}
}
6/5/2018更新
iOS 全局修改UINavigationBar的返回按钮(适配 iOS 11)
This way is no pefect when A viewcontroller which has hidden navigation bar push to B viewcontroller which will show it.
It won't hide left back title of the navigation bar in iOS11
3/2/2018更新
The following code do work perfectly before iOS11, If you want hide back title of the navigation bar.
UIBarButtonItem.appearance()
.setBackButtonTitlePositionAdjustment(UIOffsetMake(0,-300), for:UIBarMetrics.default)