状态栏文本颜色 iOS 7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19065098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Status Bar Text Color iOS 7
提问by AJ112
I am unable to change the text colour in the status bar in iOS 7 SDK. Currently its black and i want it to be white for all my view controllers in a storyboard.
我无法更改 iOS 7 SDK 状态栏中的文本颜色。目前它是黑色的,我希望它在故事板中的所有视图控制器都是白色的。
I have seen few questions on StackOverflow like THIS, THISand THISbut they didn't of much help. Also may be due to the fact that i am unable to find UIViewControllerBasedStatusBarAppearance to YES in my plist file.
我在 StackOverflow 上看到过像THIS、THIS和THIS这样的几个问题,但它们没有多大帮助。也可能是因为我无法在我的 plist 文件中找到 UIViewControllerBasedStatusBarAppearance 为 YES 。
Can any one tell me the right way to set the status bar text colour to white for all view controllers in the storyboard? Thanks in advance!
任何人都可以告诉我将故事板中所有视图控制器的状态栏文本颜色设置为白色的正确方法吗?提前致谢!
回答by KC.
Let me give you a complete answer to your question. Changing the status bar text colour is very easy but its a little confusing in iOS 7 specially for newbies.
让我给你一个完整的回答你的问题。更改状态栏文本颜色非常容易,但在 iOS 7 中对于新手来说有点令人困惑。
If you are trying to change the colour from black to white in StoryBoard by selecting the view controller and going to Simulated Metrics on the right side, it won't work and i don't know why. It should work by changing like this but any how.
如果您尝试通过选择视图控制器并转到右侧的模拟指标来将 StoryBoard 中的颜色从黑色更改为白色,它将不起作用,我不知道为什么。它应该通过像这样改变来工作,但无论如何。
Secondly, you won't find UIViewControllerBasedStatusBarAppearance property in your plist but by default its not there. You have to add it by yourself by clicking on the + button and then set it to NO.
其次,您不会在 plist 中找到 UIViewControllerBasedStatusBarAppearance 属性,但默认情况下它不存在。您必须通过单击 + 按钮自行添加它,然后将其设置为 NO。
Lastly, you have to go to your AppDelegate.m file and add the following in didFinishLaunchingWithOptions method, add the following line:
最后,您必须转到 AppDelegate.m 文件并在 didFinishLaunchingWithOptions 方法中添加以下内容,添加以下行:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
This will change the colour to white for all your view controllers. Hope this helps!
这会将所有视图控制器的颜色更改为白色。希望这可以帮助!
回答by AbdullahC
If you're looking for UIViewControllerBasedStatusBarAppearance
, you'll need to click the little plus sign that appear when you hover over the root element in your plist file.
如果您正在寻找UIViewControllerBasedStatusBarAppearance
,则需要单击将鼠标悬停在 plist 文件中的根元素上时出现的小加号。
Once you do that, a new row will appear - select "View controller-based status bar appearance" from the dropdown list and set NO
as its value. (That friendly name is declared internally as UIViewControllerBasedStatusBarAppearance
)
执行此操作后,将出现一个新行 - 从下拉列表中选择“查看基于控制器的状态栏外观”并设置NO
为其值。(该友好名称在内部声明为UIViewControllerBasedStatusBarAppearance
)
Next, calling the following method in your app delegate should set the status bar color to white for all view controllers:
接下来,在您的应用程序委托中调用以下方法应该将所有视图控制器的状态栏颜色设置为白色:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
回答by Claudia Mardegan
Set the UIViewControllerBasedStatusBarAppearance
to YES in the plist
UIViewControllerBasedStatusBarAppearance
在 plist 中设置为 YES
In viewDidLoad
do a [self setNeedsStatusBarAppearanceUpdate];
在viewDidLoad
做一个[self setNeedsStatusBarAppearanceUpdate];
Add the following method:
添加以下方法:
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
回答by Leo Natan
It is YES
by default, so you won't see it. You need to add
它是YES
默认的,所以你不会看到它。你需要添加
UIViewControllerBasedStatusBarAppearance
to your plist and set it to NO
.
到您的 plist 并将其设置为NO
.
Then you can call
然后你可以打电话
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];