在info.plist文件里,把View controller-based status bar appearance设置成YES,那表明view controller中设置状态栏的优先级高于application的设置。为NO,则表明以application为准,view controller中的方法无效。
1 View controller-based status bar appearance设置成YES,则需要在view controller中调用setNeedsStatusBarAppearanceUpdate来进行控制状态栏的显示。
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setNeedsStatusBarAppearanceUpdate];
[self prefersStatusBarHidden];
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
2 View controller-based status bar appearance设置成NO,则使用
[[UIApplication sharedApplication] setStatusBarHidden:YES];