IOS7状态栏

来源:互联网 发布:查看oracle数据库oid 编辑:程序博客网 时间:2024/05/21 07:51

The UINavigationController does not forward on preferredStatusBarStyle calls to its child view controllers. Instead it manages it's own state - as it should, it is drawing at the top of the screen where the status bar lives and so should be responsible for it. Therefor implementingpreferredStatusBarStyle in your VCs within a nav controller will do nothing - it will never be called.

The trick is what the UINavigationController uses to decide what to return forUIStatusBarStyleDefault or UIStatusBarStyleLightContent. It bases this on it'sUINavigationBar.barStyle. The default (UIBarStyleDefault) results in the dark foregroundUIStatusBarStyleDefault status bar style. And UIBarStyleBlack will give aUIStatusBarStyleLightContent status bar.

TL;DR:

If you want UIStatusBarStyleLightContent on a UINavigationController use:

self.navigationController.navigationBar.barStyle = UIBarStyleBlack; (chenyong后来我在我的viewcontroller里加这句话实现,并未增加

preferredStatusBarStyle

那三个方法且 View controller-based status bar appearance 也是默认的YES)
转载自:http://stackoverflow.com/questions/19022210/preferredstatusbarstyle-doesnt-to-get-called
0 0
原创粉丝点击