UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent,animated: true)
我使用这个在所有应用程序中将状态栏更改为亮.但现在我需要在一个View Controller中将其更改为黑色.我怎样才能做到这一点?
解决方法
将project.plist中基于视图控制器的状态栏外观设置为NO
使用viewWillAppear并将viewWillDisappear设置和重置statusBarStyle,同时保持一个属性与之前的statusBarStyle一样
let initialStatusBarStyle : UIStatusBarStyle func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) initialStatusBarStyle = UIApplication.sharedApplication().statusBarStyle UIApplication.sharedApplication().setStatusBarStyle(.LightContent,animated: animated) } func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) UIApplication.sharedApplication().setStatusBarStyle(initialStatusBarStyle,animated: animated) }