Showing posts with label UIApplication setStatusBarStyle animated example. Show all posts
Showing posts with label UIApplication setStatusBarStyle animated example. Show all posts

Wednesday, May 29, 2013

UIApplication setStatusBarStyle animated example in Objective C (iOS).

UIApplication setStatusBarStyle animated


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 animated]
The animation slides the status bar out toward the top of the interface.


UIApplication setStatusBarStyle animated example.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent
                                            animated:YES];

Example of [UIApplication setStatusBarStyle animated].
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
}

UIApplication setStatusBarStyle animated 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];
}

End of UIApplication setStatusBarStyle animated example article.