How to hide a status bar in iOS?

user1680822 picture user1680822 · Sep 30, 2012 · Viewed 115.5k times · Source

I can hide a status bar in my app:

- (void)viewDidLoad{
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    [super viewDidLoad];
    }

When I chose my launch image and start it first time, it's status bar over a picture. How can I hide this?

Answer

Charan picture Charan · Sep 30, 2012

You need to add this code in your AppDelegate file, not in your Root View Controller

Or add the property Status bar is initially hidden in your plist file

enter image description here

Folks, in iOS 7+

please add this to your info.plist file, It will make the difference :)

UIStatusBarHidden UIViewControllerBasedStatusBarAppearance

enter image description here

For iOS 11.4+ and Xcode 9.4 +

Use this code either in one or all your view controllers

override var prefersStatusBarHidden: Bool { return true }