merocode

Let's reveal the code!

Posts Tagged ‘statusbar’

Extend the navigation bar to status bar

Sometimes you may need to create a navigation bar for a view controller that is not part of navigation controller; like for example when display this view controller modally.

Then you will notice this navigation bar doesn’t extend to status bar.

So in your view controller implementation file, you should implement the following method of the UIBarPositioningDelegate .

Remember to add the following code to your view controller header file, to conform the class to UIBarPositioningDelegate protocol; because UINavigationBarDelegate extends UIBarPositioningDelegate.

Then back in your view controller implementation file, assign the delegate for the navigation bar in the viewDidLoad method assuming your navigation bar object called navBar.