I tried to do the same. The method I use for this is based on the following concepts:
- A background image with a height of 64 points will fill both the UINavigationBar and UIStatusBar.
- A 44-pixel-high background image will fill the UINavigationBar and leave the UIStatusBar black.
- You can add a subview to the top of the current navigationController view, and it will be under the UIStatusBar.
So, firstly, you need to create two images with the desired visibility of the UINavigationBar:
640x128px image to display the navigation bar and status bar ( ImageA )

And a 640x88px image to cover the navigation bar, but leave the status bar black ( ImageB ).

In the application:didFinishLaunchingWithOptions: set the background of your UINavigationBar using ImageA using [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"ImageA.png"] forBarMetrics:UIBarMetricsDefault];
When the side menu starts to open, you need to switch the UINavigationBar so that it uses ImageB and creates a view that you add under the UIStatusBar. Here is a sample code for this:
// Add a property for your "temporary status bar" view @property (nonatomic, strong) UIView *temporaryStatusBar;
And in the code where the side menu opens:
// Create a temporary status bar overlay self.temporaryStatusBar = [[UIView alloc] initWithFrame:[[UIApplication sharedApplication] statusBarFrame]]; self.temporaryStatusBar.backgroundColor = [UIColor yourColor]; [self.navigationController.view addSubview:self.temporaryStatusBar]; // Update both the current display of the navigationBar and the default appearance values [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"imageB.png"] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"imageB.png"] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setNeedsDisplay];
When the side menu animates open or when the user clicks the menu, all you have to do is adjust the alpha level of the UIStatusBar overlay. When the side menu is fully open, the UINavigationBar should have ImageB as the background image, and the UIStatusBar overlay should have alpha 0. If the side menu closes, you will want to replace the UINavigationBar with ImageA and remove the UIStatusBar overlay.
Let me know if this works for you!
source share