UIStatusBarStyle PreferredStatusBarStyle 不适用于 iOS 7 [英] UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7

查看:20
本文介绍了UIStatusBarStyle PreferredStatusBarStyle 不适用于 iOS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我使用 Xcode 5 为 iOS 7 构建的 iPhone 应用程序中,我在 info.plist 和我的 ViewController 中设置了 UIViewControllerBasedStatusBarAppearance=YES有这个代码:

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
{
    return UIStatusBarStyleLightContent;
}

但是状态栏在黑色背景下仍然是黑色的.

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

我知道可以通过在 info.plist 中设置 UIViewControllerBasedStatusBarAppearance=NO 来更改此应用程序范围,但我实际上需要在 viewController 上更改此设置 在运行时由 viewController 基础.

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.

推荐答案

好的,诀窍就在这里.您必须添加键基于控制器的状态栏"并将值设置为否.

OK, here's the trick. You do have to add the key "View controller-based status bar" and set the value to No.

这和这个key的意思是相反的,但是即使你把值设置为No,你仍然可以改变状态栏的外观,无论是显示还是不在任何视图控制器中.所以它的行为类似于是",但将其设置为否"!

This is counter to what it appears the meaning of this key is, but even if you set the value to No, you can still change the appearance of the status bar, and whether it shows or not in any view controller. So it acts like "Yes" but set it to "No"!

现在我可以让状态栏变白或变暗.

Now I can get the status bar white or dark.

这篇关于UIStatusBarStyle PreferredStatusBarStyle 不适用于 iOS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆