Mastering iOS 7 UIStatusBarStyle

iOS 7 introduces the UIViewControllerBasedStatusBarAppearance plist setting allowing us to change the statusBar’s text color when the main viewController changes.

Getting it to work can feel tricky however.

  1. Ensure you set UIViewControllerBasedStatusBarAppearance to boolean YES in your plist.
  2. Ensure you set still set the default statusBar style in your plist, this will show during the splash screen.
  3. Override preferredStatusBarStyle providing your viewController is not inside aUINavigationController.
  4. If your viewController is inside a navigationController then preferredStatusBarStyle seems to be ignored completely. Instead the navigationController’s navigationBar’s barStyle is used. A Dark barStyle makes the statusBar white, the default barStyle makes the statusBar text black.

This in fact makes some sense. The application queries the main viewController’s preferredStatusBar style, so if you have a navigationController the main viewController is the navigationController.


//work when UIViewControllerBasedStatusBarAppearance==NO
//no matter whether there is UINavigationController
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];



from:https://coderwall.com/p/hitv1q

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值