第一种方式:
1.在info.plist 增加字段View controller-based status bar appearance并设置为yes
2.在自定义customTabbarViewController里面设置
- (UIStatusBarStyle)preferredStatusBarStyle {
returnself.selectedViewController.preferredStatusBarStyle;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
returnself.topViewController.preferredStatusBarStyle;
}
4.在MMDrawerController里面设置(以右边抽屉为例)- (UIStatusBarStyle)preferredStatusBarStyle {
returnself.rightDrawerViewController.preferredStatusBarStyle;
}
-(void)viewWillAppear:(BOOL)animated{
[superviewWillAppear:YES];
[selfsetNeedsStatusBarAppearanceUpdate];
}
- (UIStatusBarStyle)preferredStatusBarStyle
{
//返回白色
returnUIStatusBarStyleLightContent;
//返回黑色
// return UIStatusBarStyleDefault;
}
- (BOOL)prefersStatusBarHidden
{
returnYES;//返回NO表示要显示,返回YES将hiden
}
第二种方案:
1.在info.plist 增加字段View controller-based status bar appearance并设置为no
2.-(void)viewWillAppear:(BOOL)animated{
[superviewWillAppear:YES];
[[UIApplicationsharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}