Back Button Tint Color

46 Views Asked by At

How can I change the back button of a certain navigation controller. I have tried to use

override func viewDidLoad() {
    super.viewDidLoad()
    navigationItem.backBarButtonItem?.tintColor = UIColor.red
}

I know that if i use navigationController it will change the back button tint color on all of my view controllers.

1

There are 1 best solutions below

0
SEUNGHWAN LEE On BEST ANSWER

Try this!!

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationController?.navigationBar.tintColor = .red
    }
    
    override func willMove(toParent parent: UIViewController?) {
        self.navigationController?.navigationBar.tintColor = // original color
    }
}