1.在 info.plist 添加View controller-based status bar appearance 设置为NO
2 在AppDelegate.m 的方法中如下设置,默认会显示黑色
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//设置全局状态栏颜色为黑色
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
//设置全局状态栏颜色为白色
// [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
return YES;
}
3.在其他页面设置状态栏的颜色
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}