UIApplication setStatusBarStyle
Sets the style of the status bar, optionally animating the transition to the new style.
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated
Parameters
statusBarStyle
A constant that specifies a style for the status bar. See the descriptions of the constants in UIStatusBarStyle for details.
animated
YES if the transition to the new style should be animated; otherwise NO .
Discussion of [UIApplication setStatusBarStyle]
The animation slides the status bar out toward the top of the interface.
UIApplication setStatusBarStyle example.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent
animated:YES];
animated:YES];
Example of [UIApplication setStatusBarStyle].
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
}
[super viewDidAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
}
UIApplication setStatusBarStyle example.
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// don't forget to set navigationBar.translucent to YES
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
[UINavigationBar setAnimationDuration:3.0];
[UINavigationBar beginAnimations:@"" context:nil];
[[UIApplication sharedApplication] setStatusBarHidden:!([UIApplication sharedApplication].statusBarHidden) withAnimation:NO];
if ([UIApplication sharedApplication].isStatusBarHidden)
[self.navigationController.navigationBar setAlpha:0.0];
else [self.navigationController.navigationBar setAlpha:1.0];
[UINavigationBar commitAnimations];
}
{
// don't forget to set navigationBar.translucent to YES
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
[UINavigationBar setAnimationDuration:3.0];
[UINavigationBar beginAnimations:@"" context:nil];
[[UIApplication sharedApplication] setStatusBarHidden:!([UIApplication sharedApplication].statusBarHidden) withAnimation:NO];
if ([UIApplication sharedApplication].isStatusBarHidden)
[self.navigationController.navigationBar setAlpha:0.0];
else [self.navigationController.navigationBar setAlpha:1.0];
[UINavigationBar commitAnimations];
}
End of UIApplication setStatusBarStyle example article.