0

I am trying to change the default backBarButtonItem colour to white colour,

my codes look like below

self.navigationItem.backBarButtonItem?.tintColor = UIColor.whiteColor()

But It is not working for me, any ideas?

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
Joey Zhang
  • 363
  • 6
  • 18

3 Answers3

6

Try this:

self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
Nyfa117
  • 256
  • 1
  • 6
1

If you want to change the backBarButton do this :

override func viewDidLoad() {

    super.viewDidLoad()

    let newBackButton = UIBarButtonItem(title: "B",
    style: UIBarButtonItem.Style.plain, target: self, action: "backAction")
        navigationController?.navigationBar.topItem?.backBarButtonItem = newBackButton
    newBackButton.tintColor = .red
    // Do any additional setup after loading the view.
}

func backAction() -> Void {
    self.navigationController?.popViewController(animated: true)
}

image of code

See the result:
see the result

David Buck
  • 3,752
  • 35
  • 31
  • 35
Hjd959
  • 26
  • 5
0

Try this:

self.navigationController?.navigationItem.backBarButtonItem?.tintColor = UIColor.red

Vishal Vaghasiya
  • 4,618
  • 3
  • 29
  • 40
Hjd959
  • 26
  • 5