下面截图给出修改 iOS 状态栏颜色的 4 种方式
![](http://upload-images.jianshu.io/upload_images/251884-b5c68bd4596c0eab.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Target.png
![](http://upload-images.jianshu.io/upload_images/251884-c491e2ad56b39242.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Info.plist.png
![](http://upload-images.jianshu.io/upload_images/251884-a59c6415673d6714.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Storyboard.png
![](http://upload-images.jianshu.io/upload_images/251884-40cace6ffedf0879.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
code.png
其中第四张图中的代码,直接写在你的任何一个 ViewController 的 class 里面就可以。
然而,以上 4 种方法存在两个问题:
1.无法在某一个 ViewController 里面任意切换
2.优先级不够高,可能会失效
下面祭出第 5 种方法:
首先去 Info.plist 里面,把 UIViewControllerBasedStatusBarAppearance 设置为 NO.
![](http://upload-images.jianshu.io/upload_images/251884-bce6e75aa4853ce9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
info.plist.png
然后在你想要改变状态栏颜色的任何地方,写下面这行代码
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent, animated: true]