我的应用程序背景是黑色的,但在iOS 7中,状态栏变成了透明的。所以我什么也看不见,只有角落里的绿色电池指示灯。如何将状态栏文本颜色改为白色,就像在主屏幕上一样?


当前回答

转到项目->目标, 然后设置“状态栏样式”为“亮”。它使状态栏从启动屏幕变成白色。 然后在Info.plist中将“基于视图控制器的状态栏外观”设置为“NO”。

其他回答

在Swift 3非常简单,只需2步。 去你的信息。将基于视图控制器的状态栏外观更改为“NO”。 然后在Appdelegate中在didfinishlaunchingwithoptions方法中添加这一行

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        UIApplication.shared.statusBarStyle = .lightContent
        return true
    }

这在iOS9中已经被弃用,现在你应该在rootviewcontroller中重写这个属性

这样做在iOS 9中已经被弃用,应该在rootviewcontroller上这样做

override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
 }

如果你有一个通过Interface Builder创建的嵌入式导航控制器,请确保在管理导航控制器的类中设置以下内容:

-(UIStatusBarStyle)preferredStatusBarStyle{ 
    return UIStatusBarStyleLightContent; 
} 

这应该就是你所需要的。

请试试这个

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [application setStatusBarHidden:NO];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
        statusBar.backgroundColor = [UIColor blackColor];
    }

这适用于Golden Master iOS7和Xcode 5 GM种子和2013年9月18日发布的iOS7 SDK(至少导航控制器隐藏):

中的UIViewControllerBasedStatusBarAppearance设置为NO Info.plist。 在ViewDidLoad方法或任何地方,你想改变的地方 状态栏样式: [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

如果你的UIViewController在UINavigationController中,你必须设置BarStyle:

-[UINavigationBar setBarStyle:UIBarStyleBlack]

原始答案在这里

https://devforums.apple.com/message/844264#844264