ios状态栏颜色问题解决方案

http://stackoverflow.com/questions/17678881/how-to-change-status-bar-text-color-in-ios-7上有很多解决方案,但一直不成功,后来仔细看了下面评论,问题解决。

http://stackoverflow.com/questions/19022210/preferredstatusbarstyle-isnt-called/19513714#19513714

The UINavigationController does not forward on preferredStatusBarStyle calls to its child view controllers. Instead it manages its 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 implementing preferredStatusBarStyle in your VCs within a nav controller will do nothing – they will never be called.

The trick is what the UINavigationController uses to decide what to return for UIStatusBarStyleDefault or UIStatusBarStyleLightContent. It bases this on it’s UINavigationBar.barStyle. The default (UIBarStyleDefault) results in the dark foreground UIStatusBarStyleDefault status bar. And UIBarStyleBlack will give a UIStatusBarStyleLightContent status bar.

If you want UIStatusBarStyleLightContent on a UINavigationController use:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;


Post a Comment