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


当前回答

你可以从info.plist:

1)“基于视图控制器的状态栏外观”设置为“NO”

2)“状态栏样式”设置为“UIStatusBarStyleLightContent”

done

其他回答

只需以下两步:

步骤1:

在项目目标的Info选项卡下,添加行:

UIViewControllerBasedStatusBarAppearance,设置值NO。

步骤2:

在项目AppDelegate.m中:

- (BOOL)application:(UIApplication *)application 
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    …
    [application setStatusBarStyle:UIStatusBarStyleLightContent];
    …
}

在信息。plist设置“视图基于控制器的状态栏外观”为NO

在AppDelegate中添加

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

不需要做一些额外的,只是写这段代码在你的viewController和获得状态栏颜色白色

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

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

-[UINavigationBar setBarStyle:UIBarStyleBlack]

原始答案在这里

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