iOS 7和更高版本:为每个视图控制器设置状态栏样式 [英] iOS 7 and later: set status bar style per view controller
问题描述
我尝试了很多方法来设置状态栏样式(默认或lightcontent),但不能让它在每个视图控制器基础上工作。我可以为整个应用程序设置状态栏样式。
I tried many ways to set the status bar style (default or lightcontent) but can't get it to work on a per view controller basis. I can set the status bar style for the whole app only.
任何人都有提示?
尝试 UIViewControllerBasedStatusBarAppearance
和
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
但无效。
谢谢!
推荐答案
您尝试过吗?
-
设置查看基于控制器的状态栏外观(
UIViewControllerBasedStatusBarAppearance
)为YES
在您的Info.plist。 (YES
是默认值,因此您也可以将此值从您的plist中删除。)
Set "View controller-based status bar appearance" (
UIViewControllerBasedStatusBarAppearance
) toYES
in your Info.plist. (YES
is the default, so you can also just leave this value out of your plist.)
在您的viewDidLoad方法中,调用 [self setNeedsStatusBarAppearanceUpdate]
In your viewDidLoad method, call [self setNeedsStatusBarAppearanceUpdate]
.
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
这篇关于iOS 7和更高版本:为每个视图控制器设置状态栏样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!