How to hide bar button item

You can hide it by disable the button & change it tintColor like that,

self.navigationItem.rightBarButtonItem?.isEnabled = false
self.navigationItem.rightBarButtonItem?.tintColor = UIColor.clear

do it right or left BarButtonItem whatever you preferred. Hope it helps.


you can hide it like this:

self.navigationItem.leftBarButtonItem = nil

and you can add a new left button like this:

self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Button", style: .Plain, target: self, action: #selector(ViewController.buttonTapped))

I hope that helps,

Cheers


Swift 3.1 | Works great to hide my rightBarButton

  // viewDidLoad 
  self.rightBarButtonAlert.isEnabled = false
  self.rightBarButtonAlert.tintColor = .clear

Before:

enter image description here

After:

enter image description here