Wednesday, May 29, 2013

UIApplication setStatusBarHidden withAnimation example in Objective C (iOS).

UIApplication setStatusBarHidden withAnimation


Hides or shows the status bar, optionally animating the transition.

- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation

Parameters
hidden
YES to hide the status bar, NO to show the status bar.
animation
A constant that indicates whether there should be an animation and, if one is requested, whether it should fade the status bar in or out or whether it should slide the status bar in or out.

Discussion of [UIApplication setStatusBarHidden withAnimation]
See the descriptions of the constants of the UIStatusBarAnimation type for more information.


UIApplication setStatusBarHidden withAnimation example.
if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden: withAnimation:)])
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
else
    [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];

Example of [UIApplication setStatusBarHidden withAnimation].
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#if __IPHONE_OS_VERSION_MIN_REQUIRED > 30100
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:YES];
#else
    [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
#endif
#endif

UIApplication setStatusBarHidden withAnimation example.
if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden: withAnimation:)])
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
else if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden: animated:)])
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
}
else if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden:)])
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}

End of UIApplication setStatusBarHidden withAnimation example article.