When hiding the statusbar my navigation bar moves up in iOS7

Tim Wachter picture Tim Wachter · Oct 2, 2013 · Viewed 7.1k times · Source

I am trying to hide the statusbar but maintain the "bigger" navigationbar height. Right now when I hide the statusbar by setting - (BOOL)prefersStatusBarHidden to YES and then calling [self setNeedsStatusBarAppearanceUpdate];. The problem with this is that the navigationbar will slide up and won't leave space for the notification I'm trying to show. Simply adding a view over the statusbar is not an option, our statusbar/navigation has the fancy blur effect. Does anyone have a clue how to maintain the standard navigationbar height with the status bar height and remove the statusbar from that?

Edit; what I ended up doing is taking a risk and getting the UIWindow of the statusbar via a private API and offsetting that.

Edit 2; App got approved with the private API. Be cautious though!

Answer

Rahul Mathur picture Rahul Mathur · Jun 2, 2014

You can create a custom UIView with its frame as

customView.frame=CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height);

Also hide your status bar by following the below steps

Go to info.plist and add two attributes if not present. set "Status bar is initially hidden" to YES and set UIViewControllerBasedStatusBarAppearance to NO. This will hide status bar for your app.