I have an IBOutlet that I have linked to from the storyboard
@IBOutlet var creeLigueBouton: UIBarButtonItem!
and I want to make it disappea
It is quite late to reply but looking for an answer for my problem I found this topic. The marked answer did not help me, but I managed to solve my problem thanks to @haiLong's answer. My solution works for all types of bar buttons... I think. Add this to your ViewController and use as needed.
var tintColorsOfBarButtons = [UIBarButtonItem: UIColor]()
func hideUIBarButtonItem(button: UIBarButtonItem) {
if button.tintColor != UIColor.clear {
tintColorsOfBarButtons[button] = button.tintColor
button.tintColor = UIColor.clear
button.isEnabled = false
}
}
func showUIBarButtonItem(button: UIBarButtonItem) {
if tintColorsOfBarButtons[button] != nil {
button.tintColor = tintColorsOfBarButtons[button]
}
button.isEnabled = true
}
I hope it saves some time to other developers :)