I created a toolbar in IB with several buttons. I would like to be able to hide/show one of the buttons depending on the state of the data in the main window.
For Swift 3 and Swift 4 you can do this to hide the UIBarButtomItem:
self.deleteButton.isEnabled = false
self.deleteButton.tintColor = UIColor.clear
And to show the UIBarButtonItem:
self.deleteButton.isEnabled = true
self.deleteButton.tintColor = UIColor.blue
On the tintColor you must have to specify the origin color you are using for the UIBarButtomItem