UINavigationBar Archives

How to hide navigation elements with swishy animations

You can hide (and show) navigation bars and toolbars from your UINavigationController with extremely funky animations, much like we see in the Photos app on iOS. In the app, when you single-tap the screen, both top and bottom toolbars disappear. Here’s how we do that: Provided you have your view controller embedded in a UINavigationController, […]

How to create a UIBarButtonItem in code and make it call a method

Some things are really easy to do via a Storyboard – but when you want to create the same thing in code I frequently forget how to do it. Turns out it’s equally simple: this example assumes you have a View Controller which is embedded in a Navigation Controller (so it already has a UINavigationBar […]

How to change the back button text on a UINavigationController

In Your Storyboard I didn’t know the storyboard could do this, but it can: Select the Navigation Bar in question, then check the Attributes Inspector: In Code To set the title in code, you need to address the self.navigationItem.backBarButton property of your view controller and pass it a new UIBarButtonItem. Here’s one way of doing […]