状态栏的字体为黑色: UIStatusBarStyleDefault
状态栏的字体为白色: UIStatusBarStyleLightContent
iOS6 -- iOS9
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
iOS7 -- iOS9 :
- (UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
Info.plist 里面,把 UIViewControllerBasedStatusBarAppearance 设置为 NO.
info.plist.png
然后在你想要改变状态栏颜色的任何地方,写下面这行代码
UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.Default, animated: true)
或UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)