How to remove all navigationbar back button title

后端 未结 30 3401
后悔当初
后悔当初 2020-12-12 15:42

When I push a UIViewController, it has some title in back button at new UIViewController, if the title has a lot of text, It does not look good in

30条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 16:05

    Just use this:

    func removeBackButton(vc:UIViewController) {
            let button = UIButton.init(type: .custom)
            button.setImage(UIImage.init(named:""), for: .normal)
            let leftBarButton = UIBarButtonItem.init(customView: button)
            vc.navigationItem.leftBarButtonItem = leftBarButton
    }
    

    So call this method in viewDidLoad:

    override func viewDidLoad() {
            super.viewDidLoad()
         removeBackButton(vc:self)
    }
    

提交回复
热议问题