码迷,mamicode.com
首页 > 移动开发 > 详细

UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7

时间:2014-09-09 17:55:59      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   ar   strong   for   art   

Q:

In my iPhone application built with Xcode 5 for iOS 7 I set UIViewControllerBasedStatusBarAppearance=YES in info.plist, and in my ViewController I have this code:

-(UIStatusBarStyle) preferredStatusBarStyle{
    returnUIStatusBarStyleLightContent;
}

But the status bar is still black against the black background.

I know its possible to change this app-wide by setting UIViewControllerBasedStatusBarAppearance=NO in info.plist, but I actually need to alter this on a viewController by viewController basis at runtime.

 

A:

I discovered that if your ViewController is inside a navigationController then the navigationController’s navigationBar.barStyle determines the statusBarStyle.

Setting your navigationBar’s barStyle to UIBarStyleBlackTranslucent will give white status bar text (ie. UIStatusBarStyleLightContent), and UIBarStyleDefault will give black status bar text (ie. UIStatusBarStyleDefault).

Note that this applies even if you totally change the navigationBar’s color via its barTintColor.

UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7

标签:style   blog   color   os   io   ar   strong   for   art   

原文地址:http://www.cnblogs.com/lingzhao/p/3962821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!