0

guys, I want to hide the status bar in the code. After loaded view, the status bar will show and it will automatically hide after a while. How to do that?

4 Answers 4

3

You want UIApplication's setStatusBarHidden:withAnimation:

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

See the docs.

Sign up to request clarification or add additional context in comments.

Comments

0

Haven't tested it and there might be a better way but if you put the following in your load view function:

[self performSelector:@selector(hideNavBar) withObject:nil afterDelay:0.0];

and then have this function

-(void) hideNavBar {
    if (self.navigationController.navigationBar.hidden == NO)
    {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
}

You might have to hide the navigation bar in a view animation block. but some combination should work

Check out link

Comments

0

You could simply do it in you AppDelegate, when applicationDidBecommeActive ("After loaded view"). Set hide status after 400ms, with UIView animation block and calculate your root view controller's navigation bar

// AppDelegate.m

#import "AppDelegate.h"
#import "SomeViewController.h"

@interface AppDelegate ()
@property (nonatomic, strong) SomeViewController *someViewController;
@end

@implementation AppDelegate

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    UINavigationBar *navBar = self.someViewController.navigationController.navigationBar;
    if (![[UIApplication sharedApplication] isStatusBarHidden]) {
       [[UIApplication sharedApplication] setStatusBarHidden:YES
                                               withAnimation:UIStatusBarAnimationSlide];
       [UIView animateWithDuration:0.4
                        animations:^{
                            navBar.frame = CGRectMake(navBar.frame.origin.x, 0, navBar.frame.size.width, navBar.frame.size.height);
                     } completion:nil];
    }
}

@end

that's it, "After loaded view (didBecomeActive), the status bar will show and it will automatically hide after a while (400ms)"

Comments

0

You have to select your project and select Hide during application launch inside the header General, section Deployment Info like this:

enter image description here

And inside the info.plist set the View controller-based status bar to NO:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.