UIStatusBarStyle PreferredStatusBarStyle在iOS 7上不起作用 [英] UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7

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

问题描述

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

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.

我知道可以通过在中设置 UIViewControllerBasedStatusBarAppearance = NO 来更改此应用范围info.plist ,但实际上我需要在 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.

这与此键的含义相反,但即使您将值设置为,您仍然可以更改状态栏的外观,以及它是否在任何视图控制器中显示。因此它的行为类似于是,但将其设置为否!

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天全站免登陆