24

Is there a way to hide the status bar when the app's launch image is displayed and then bring it back? My app has a black status bar and the one displayed over the launch image is grey.

Is there any solution for this?

Sergey Grischyov
  • 11,995
  • 20
  • 81
  • 120

5 Answers5

50

Use this code for hiding status bar:

ObjectiveC:

[[UIApplication sharedApplication] setStatusBarHidden:YES
 withAnimation:UIStatusBarAnimationSlide];

Swift:

UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .Slide)

If you don't need status bar in the beginning. Add this setting (UIStatusBarHidden) in your Info plist file:

Status bar is initially hidden

with a value of YES.

Use this code anywhere in the app to show the status bar for that particular View Controller

ObjectiveC:

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

Swift:

UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: .Slide)
Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
Hemant Dixit
  • 1,145
  • 8
  • 12
  • Another thing to note is the `wantsFullScreen` property of UIViewController. – Moshe Aug 08 '12 at 15:21
  • 1
    Where is the best place to put `UIApplication` code you've pasted? – syntagma Sep 07 '12 at 07:32
  • I put that in did launch and I have all view controllers extending a base controller. I have a login in storyboard and a main storyboard. My base controller detects the storyboard type and if login type I make this call in view load. Put this call in your appdelegate:didlaunch and also in your viewdidload of your base controller(or view controller if you like to type a lot) – Nick Turner Mar 22 '13 at 14:18
  • Status bar is initially hidden = YES in the infoplist did the trick thanks! – user3344977 Mar 21 '16 at 22:19
  • @HardikAmal add `application.isStatusBarHidden = false` in `application(didFinishLaunchingWithOptions:)` – rafalkitta Jan 10 '18 at 09:36
  • @rafalkitta in objective c? – Hardik Amal Jan 10 '18 at 10:40
16

Just define a key in plist file will solve your problem

enter image description here

Happy Coding:)

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
  • 4
    Unfortunately this makes my whole app go fullscreen. While I only want the launch image to be full screen. I tried putting setStatusBarHidden:NO in the viewDidLoad but the status bar overlaps with the view :( – Sergey Grischyov Aug 08 '12 at 13:04
14

You can initially add this key in the info.plist file: status bar is initially hidden=YES

Then in the app delegate, add this line in the application:didFinishLaunchingWithOptions: method:

  [[UIApplication sharedApplication] setStatusBarHidden:NO];
Steph Sharp
  • 11,462
  • 5
  • 44
  • 81
Hossam Ghareeb
  • 7,063
  • 3
  • 53
  • 64
5

To return it back:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Override point for customization after app launch

    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}
Arash Zeinoddini
  • 801
  • 13
  • 19
3

Add below key to info.plist:

"Status bar is initially hidden" and select YES as value.

Apurv
  • 17,116
  • 8
  • 51
  • 67