swiftuinavigationbarbackbarbuttonitem

How to set navigationBar back button image to default symbols?


there is one screen that i don't want to show back button symbols.

i create a empty image and change the navigation bar back button image.(code like following)

navigationController?.navigationBar.backIndicatorImage = UIImage(named: "mainicon_gray-13")
navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "mainicon_gray-13")
navigationItem.backBarButtonItem = UIBarButtonItem(title: "demo", style: .plain, target: nil, action: nil)

screen like following Picture

enter image description here

But all of backBarButtonItem changed, i need to set backBarButtonItem to default symbols "<" when i back to the view.

Is there any way to set navigation bar back button image to default image?

i want the navigationBar like following picture

enter image description here


Solution

  • following is the way that i found without change back button settings to do same event.

    use leftBarButtonItem and set popViewController to go back before screen.

    override func viewDidLoad() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "test", style: .plain, target: self,action: #selector(backViewBtnFnc))
    }
     @objc func backViewBtnFnc(){
        self.navigationController?.popViewController(animated: true)
    }