2
votes

I am creating Animated splash screen in "didFinishLaunchingWithOptions" method. Animation Splash screen duration is 2 seconds. After two seconds i am hiding the Animated Splash screen. When Animated screen appears i want to hide the status bar and when animated screen disappear i want to show the status bar.

how to do that?

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Here i am creating Animated Splash screen

***** Here i want to hide Status bar*******

splashView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 580)];
    splashView.backgroundColor =[UIColor whiteColor];
    [self.window addSubview:splashView];


    logoView = [[UIImageView alloc] initWithFrame:CGRectMake(logoX,0, 225, 25)];
    logoView.image = [UIImage imageNamed:@"logoImage"];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
    splashView.alpha = 1.0;
    logoView.frame = CGRectMake(logoX, logoY, 225, 25);

    [window addSubview:logoView];
    [window bringSubviewToFront:logoView];

    [UIView commitAnimations];

// Hiding Animated splash screen After 2 second Here

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    ************* Here i want to show  Status bar Again ***************
    [splashView removeFromSuperview];
    [logoView removeFromSuperview];
}
3

3 Answers

2
votes

You go into ProjectSettings -> General. There is an option Status Bar Style.

enter image description here

EDIT Use block. They provide really simple syntax for animations.

  [UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

     //your animation code here
     //all changes made here to frame, bounds, alpha etc. are animated

  } completion:^(BOOL finished) {
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];

     //this is called after animation finishes

  }];
1
votes

Add the following entries in your plist file:

  • "Status bar is initially hidden" = Yes: Hides the status bar at application start and in the splash screen
  • "View controller-based status bar appearance" = No: Prevents that the view controller classes show the status bar
0
votes

You can create a category for UIViewController

@implementation UIViewController (HideStatusBar)
-(BOOL)prefersStatusBarHidden
{
return YES;
}