【问题标题】:How to hide Status bar during Animated Splash Screen present in iOS7 and iOS6?如何在 iOS 7 和 iOS 6 中出现动画启动画面期间隐藏状态栏?
【发布时间】:2014-04-11 16:45:22
【问题描述】:

我正在“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];
}

【问题讨论】:

    标签: ios iphone


    【解决方案1】:

    您进入 ProjectSettings -> General。有一个选项Status Bar Style

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

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

    【讨论】:

    • 我认为我的问题不清楚我正在创建带有两个图像的动画启动屏幕。我将用代码编辑我的问题
    • 它在 iOS7 中不起作用,在 iOS 6 中起作用,但问题是动画结束后导航栏位于状态栏下方。
    • '导航栏在状态栏下' IOS6 还是 IOS 7?
    • 在 iOS6 中它位于状态栏下方。在 iOS7 中不工作
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      您可以为 UIViewController 创建一个类别

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

      【讨论】:

        猜你喜欢
        • 2016-05-18
        • 1970-01-01
        • 2013-10-11
        • 1970-01-01
        • 2021-05-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-17
        相关资源
        最近更新 更多