iOS Developers will surely knows about the issue about status bar and the famous "slide/hamburger/drawer". The issue is well explained here: http://uxmag.com/articles/adapting-ui-to-ios-7-the-side-menu
I'm using MMDrawerController library and it has a nice hack that lets us to create a dummy status bar just above the container view controller. Unfortunately this doesn't work really good. What's the news? The news is that I stumbled upon an app (Tinder) that perfectly solve this mind blowing issue. I've created a gif that perfectly shows what Tinder does.
You need to wait a few seconds for seeing the gif because there's a bug in it and I don't know how to get rid of. Just wait one/two seconds and you will able to see the gif correctly.
Anyway, what Tinder does? When the user taps on the top left menu button and begin to swipe right the status bar fades out neatly. And when the view is revert to the original position the status bar will show up again.
I am both happy and a bit sad for this because this means that a way must be to do it but I really don't know how to implement it (perhaps hacking MMDrawerController
). Any help will be so much appreciated.
IMPORTANT
Please pay attention to the fact that the method setStatusBarHidden:
will completely hide the status bar, this means that the entire view is with a height -20px. This is obviously not the solution because as you can see from the gif the view is not stretched.
You can used
-setStatusBarHidden:withAnimation:
if you adjust your views frame in-viewDidAppear:
, then you will not see any stretch. Note that autolayout is disabled.Check out the method
setStatusBarHidden:withAnimation:
onUIApplication
. It will allow you to show or hide the status bar and the animation can be none, fade, or slide. You just need to add a call to hide the bar and one to show the bar at the correct times and decide if you like the fade as you illustrated or if the slide works better for you.https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/setStatusBarHidden:withAnimation:
Here is how you should do that in iOS 7:
i don't know if it will sove your problem but i got almost the same effect using the SWRevealViewController project. In the appDelegate I've set the delegate method from this class to do this:
centerY is a category in the UIView which sets the center.y without dealing the boring part of setting frame variables.
Your main problem is with
MMDrawerController
. If you'll digg into it you'll find a lot of methods statusbar related such assetShowsStatusBarBackgroundView
setStatusBarViewBackgroundColor
and more. Something in their code pushes the view up when the statusbar is hidden.Alternatively you can use another drawer controller or use custom code.
Here's a simple way how to accomplishe this:
ViewControllerA:
ViewControllerB: (Container in ViewControllerA)
For iOS 6 compatieblty use:
The table view and other subviews will stay in their location and won't be pushed up.
Edit:
Adding a NavigationBar:
Taken from here
You could very simply subclass
UINavigationController
and create your own navbar to avoid this annoyness.