StatusBar 颜色修改方法
2017-05-07 本文已影响62人
行走的风车
方法一:全局仅使用一种颜色
要想在工程中启动和视图中的状态栏都是白色,用下面的方法在plist文件中简单配置下即可
1.设置Status Bar Style为UIStatusBarStyleLightContent

2.在plist文件中添加 View controller-based status bar appearance = NO。

方法二:不同页面需要显示不同的StatusBar颜色
1、自定义NavigationController 实现方法
- (UIViewController*) childViewControllerForStatusBarStyle{
return self.topViewController;
}

2、viewcontroller.m文件中添加如下代码,
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
另一种方法:
[UIApplicationsharedApplication].statusBarStyle=UIStatusBarStyleLightContent;
再需要设置的页面 viewwillappear中加入该设置。