如何在iOS 7中以编程方式将UIViewControllerBasedStatusBarAppearance更改为YES / NO? [英] How to change UIViewControllerBasedStatusBarAppearance to YES/NO programmatically in iOS 7?

查看:522
本文介绍了如何在iOS 7中以编程方式将UIViewControllerBasedStatusBarAppearance更改为YES / NO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序背景较暗,但在iOS 7中状态栏变得透明。所以我看不到任何东西,角落里只有绿色电池指示灯。如何将状态栏文本颜色更改为绿色或橙色,就像在主屏幕上一样?

My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only green battery indicator in the corner. How can I change the status bar text color to Green or Orange like it is on the home screen?

我知道


  1. 在plist中将 UIViewControllerBasedStatusBarAppearance 设置为 YES

viewDidLoad 执行 [self setNeedsStatusBarAppearanceUpdate];

添加以下方法:

-(UIStatusBarStyle)preferredStatusBarStyle{ 
    return UIStatusBarStyleLightContent; 
}


我如何更改 UIViewControllerBasedStatusBarAppearance 以编程方式?

How can I change UIViewControllerBasedStatusBarAppearance programmatically?

提前致谢...

推荐答案

在Info.plist中设置'查看基于控制器的状态栏外观'为NO。

In Info.plist set 'View controller-based status bar appearance' as NO.

然后,将其添加到您的didfinishlaunchingwithoptions方法中的appdelegate.m类。

then,add this in your appdelegate.m class in didfinishlaunchingwithoptions method.

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

这适用于ios 7.

this works for ios 7.

这篇关于如何在iOS 7中以编程方式将UIViewControllerBasedStatusBarAppearance更改为YES / NO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆