Hide status bar on launch image
Asked Answered
C

5

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?

Clambake answered 8/8, 2012 at 12:55 Comment(0)
T
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)
Tektite answered 8/8, 2012 at 12:58 Comment(6)
Another thing to note is the wantsFullScreen property of UIViewController.Tessellation
Where is the best place to put UIApplication code you've pasted?Variable
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)Sextans
Status bar is initially hidden = YES in the infoplist did the trick thanks!Thrombosis
@HardikAmal add application.isStatusBarHidden = false in application(didFinishLaunchingWithOptions:)Viviennevivify
@Viviennevivify in objective c?Meacham
B
16

Just define a key in plist file will solve your problem

enter image description here

Happy Coding:)

Bocock answered 8/8, 2012 at 12:57 Comment(1)
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 :(Clambake
S
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];
Straw answered 16/10, 2012 at 8:53 Comment(0)
C
5

To return it back:

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

    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}
Confidant answered 1/10, 2013 at 14:32 Comment(0)
M
3

Add below key to info.plist:

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

Manage answered 8/8, 2012 at 12:59 Comment(2)
No, I want to bring it up then, not hide it forever. How do I do it?Clambake
@SergiusGee See my answer above, please.Confidant

© 2022 - 2024 — McMap. All rights reserved.