美文网首页
How to hide back title of the na

How to hide back title of the na

作者: 南国青天 | 来源:发表于2018-05-31 17:01 被阅读7次

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)

相关文章

网友评论

      本文标题:How to hide back title of the na

      本文链接:https://www.haomeiwen.com/subject/nvaqsftx.html