首页 文章

如何在iOS 7上启动期间更改状态栏样式

提问于
浏览
53

当我启动我的应用程序时,它会显示启动图像和黑色状态栏 . 如何更改它以便状态栏在启动期间亮起?我已经在我的AppDelegate didFinishLoading方法中将状态栏外观设置为light,它适用于应用程序的其余部分 .

6 回答

  • 3

    要在 Info.plist 文件中添加此键值对:

    UIStatusBarStyle: UIStatusBarStyleLightContent
    

    默认(黑色)值为 UIStatusBarStyleDefault .

    您还可以将 ~iphone~ipad 追加到该键 .

  • 2

    2 steps

    • 这通常是开发人员知道如何操作 - 在目标设置>常规>状态栏样式>更改为灯光下 . 这将影响Info.plist包含 UIStatusBarStyleLightContent .

    • This step is often missed out - 在Info.plist中,添加 View controller-based status bar appearance 并设置为NO

  • 109

    只需在您想要的任何视图或文件中定义此方法:

    - (UIStatusBarStyle)preferredStatusBarStyle
    {
        return UIStatusBarStyleLightContent;
    }
    
    // swift 
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return .LightContent
    }
    
  • 19

    就我而言, UIStatusBarStyleLightContent 不是一个可能的选择 . 我将 Transparent black style (alpha of 0.5) 设置为我的.plist中的键 Status bar style 的值,结果是一个白色状态栏 .

  • 11

    适用于iOS7和iOS8

    您需要在 Info.plist 文件属性中设置键 Status bar style

    • 为白色状态栏设置 Opaque black styleTransparent black style (alpha of 0.5)

    • 设置 Gray style (default) 以设置黑色状态栏颜色 .

    看起来您为状态栏设置了背景样式,XCode了解状态栏的哪种颜色需要选择 . 黑暗的背景 - 白色状态栏,浅色背景 - 黑色状态栏

  • 0
    **
    
     - You must take care of these three things:
    
    **
    
    **- In info.plist file**
    Set UIViewControllerBasedStatusBarAppearance to YES
    
    **- In your view controller** in which you want change color of status bar
    add this [self setNeedsStatusBarAppearanceUpdate] in viewDidLoad
    
    **- Lastly, add this method**
    - (UIStatusBarStyle)preferredStatusBarStyle
    {
          return UIStatusBarStyleLightContent;
    }
    
    Note: If you want to set color of statusBar for all the View Controllers then steps are
    **- In info.plist file**
    Set UIViewControllerBasedStatusBarAppearance to YES
    
    **- Then add this in appDelegate**
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; // **It is deprecated in iOS 9**
    

相关问题