1.1、在 info.plist 文件增加 View controller-based status bar appearance 属性,设置值为 YES。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent*)event
{
if ( self.isPrefersStatusBarHidden) {
self.isPrefersStatusBarHidden = NO;
}else{
self.isPrefersStatusBarHidden = YES;
}
[selfsetNeedsStatusBarAppearanceUpdate];
}
2、重写控制器的方法:
//设置是否隐藏
- (BOOL)prefersStatusBarHidden {
return self.isPrefersStatusBarHidden ;
}