How to hide a UIBarButtonItem in your Navigation Controller

Since UIBarButtonItems do not have a “hidden” property, we can’t just set this to yes and it’ll disappear. Instead, we can set them to nil.

In this example we’re hiding the right item in the navigation controller:

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

3 thoughts on “How to hide a UIBarButtonItem in your Navigation Controller

  1. You can use text attributes to hide a bar button:

    barButton.enabled = false
    barButton.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.clearColor()], forState: .Normal)

    Also see my solution with UIBarButtonItem extension for the similar question:
    Make a UIBarButtonItem disapear using swift IOS
    http://stackoverflow.com/a/32139271/979986

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.