I have an IBOutlet that I have linked to from the storyboard
@IBOutlet var creeLigueBouton: UIBarButtonItem!
and I want to make it disappea
I had the same problem with a tool bar that I had to hide and show its last button. So I declared a var to hold the UIBarButtonItem and removed it from the bar or added depending on the situation like:
inside the class declared the var and linked the toolbar:
var buttonToHide : UIBarButtonItem?
@IBOutlet weak var toolbarOne: UIToolbar!
at the viewDidLoad :
buttonToHide = toolbarOne.items![toolbarOne.items!.count - 1] as? UIBarButtonItem
in my code I made the trick:
if situationOccurrsToHide {
toolbarOne.items!.removeLast()
}
or
if situationOccursToShow
{
toolbarOne.items!.append(buttonToHide!)
}
You can use the removeAtIndex or insert(buttonToHide, atIndex: xx) to remove or reinsert the button at a specific position.
You must be careful not to insert or remove the button more than once.
Hope it helps.