如何在iOS 7和iOS 6中出现的动画启动画面中隐藏状态栏?

时间:2014-03-08 11:28:19

标签: ios iphone

我在“didFinishLaunchingWithOptions”方法中创建了动画启动画面。动画启动画面持续时间为2秒。两秒钟后,我隐藏了动画启动画面。当出现动画屏幕时,我想隐藏状态栏,当动画屏幕消失时,我想显示状态栏。

怎么做?

  • (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//我在这里创建动画启动画面

** * ** 这里我要隐藏状态栏* * ** * **

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];

//隐藏动画启动画面2秒钟后

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

3 个答案:

答案 0 :(得分:2)

你进入ProjectSettings - >一般。有一个选项Status Bar Style

enter image description here

修改 使用块。它们为动画提供了非常简单的语法。

  [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 :(得分:1)

在plist文件中添加以下条目:

  • “状态栏最初是隐藏的”=是:在应用程序启动时和启动画面中隐藏状态栏
  • “查看基于控制器的状态栏外观”=否:阻止视图控制器类显示状态栏

答案 2 :(得分:0)

您可以为UIViewController创建一个类别

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