How To Effectively Hide And Show iOS Status Bar

Okay, so I will show and give you some ways to toggle the visibility of your status bar. I had an experience in one of the projects that I am handling wherein I need to show the status bar in a certain screen and then hide it from another screen. Here are some ways:

1. Hiding and Showing the Status Bar WITH ANIMATION.
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[UIView animateWithDuration:0.25 animations:^{
    self.navigationController.navigationBar.frame = self.navigationController.navigationBar.bounds;
    self.view.window.frame = CGRectMake(0, 0, appFrame.size.width, appFrame.size.height);

2. Hiding and Showing the Status Bar WITHOUT ANIMATION.
[UIApplication sharedApplication].statusBarHidden = NO;

[self setNeedsStatusBarAppearanceUpdate];

If you find this tutorial as a helpful one, please subscribe and share.

Post a Comment