iOS 7和更高版本:为每个视图控制器设置状态栏样式 [英] iOS 7 and later: set status bar style per view controller

查看:263
本文介绍了iOS 7和更高版本:为每个视图控制器设置状态栏样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试了很多方法来设置状态栏样式(默认或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; 
}

但无效。

谢谢!

推荐答案

您尝试过吗?


  1. 设置查看基于控制器的状态栏外观( UIViewControllerBasedStatusBarAppearance )为 YES 在您的Info.plist。 ( YES 是默认值,因此您也可以将此值从您的plist中删除。)

  1. Set "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance) to YES 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屋!

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