修改状态栏:
1. 修改状态栏的显示样式 白色/黑色
View controller-based status bar appearance 是否在 info.plist 中设置
设置为YES
局部:
1. -(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
}
2. - (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
(1.2)这两个方法配合使用才有效
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
}
全局:
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
设置为NO
局部:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
全局:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
2. 状态的显示和隐藏
View controller-based status bar appearance 是否在 info.plist 中设置
设置为YES
局部:
YES 隐藏 NO 显示
-(BOOL)prefersStatusBarHidden{
return YES;
}
全局:
[UIApplication sharedApplication].statusBarHidden = YES; //YES 隐藏 NO 显示
设置为NO
局部:
没有办法.
全局:
[UIApplication sharedApplication].statusBarHidden = YES; //YES 隐藏 NO 显示