Reputation: 27
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?
Upvotes: 0
Views: 606
Reputation: 6052
You have to select your project and select Hide during application launch
inside the header General, section Deployment Info
like this:
And inside the info.plist set the View controller-based status bar
to NO:
Upvotes: 0
Reputation: 826
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)"
Upvotes: 0
Reputation: 17898
You want UIApplication
's setStatusBarHidden:withAnimation:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
See the docs.
Upvotes: 3
Reputation: 2381
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
Upvotes: 0