UIViewControllerBasedStatusBarAppearance作用的实际测试


        在作iOS7的适配时,很多文章都会提到UIViewControllerBasedStatusBarAppearance。便一直不是太明白其实际作用。在网上也没有查出明确的说明,苹果的官方文档也是说的不太清楚。在实际测试后发现UIViewControllerBasedStatusBarAppearance的实际作用如下:

        这个属性只影响如何设置status bar上字体的颜色是黑色还是白色,对status bar的背景色无影响。status bar的背景色在iOS7上永远是透明的。

UIViewControllerBasedStatusBarAppearance = NO时:

UIApplication 的setStatusBarStyle方法生效:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

viewController的preferredStatusBarStyle方法无效:
- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

UIViewControllerBasedStatusBarAppearance = YES时:

UIApplication 的setStatusBarStyle无效。

viewController的preferredStatusBarStyle方法有效。


apple官方说明:

UIViewControllerBasedStatusBarAppearance (Boolean - iOS) specifies whether the status bar appearance is based on the style preferred by the view controller that is currently under the status bar. When this key is not present or its value is set to YES, the view controller determines the status bar style. When the key is set to NO, view controllers (or the app) must each set the status bar style explicitly using the UIApplication object.

google自动翻译的经果:

UIViewControllerBasedStatusBarAppearance(布尔 - IOS)指定状态栏的外观是否是基于视图控制器,是目前在状态栏中的首选风格。当这个键不存在,或者它的值设置为YES时,视图控制器决定了状态栏的风格。当按键被设置为NO,视图控制器(或应用程序)都必须显式使用的UIApplication对象中的每个设置状态栏的风格。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值