//监听UIWindow隐藏
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(startVideoFullScreen) name:UIWindowDidBecomeVisibleNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(endVideoFullScreen) name:UIWindowDidBecomeHiddenNotification object:nil];
#pragma mark - noti
- (void)startVideoFullScreen{
self.hiddenBar = YES;
// 更新状态栏
[self setNeedsStatusBarAppearanceUpdate];
}
- (void)endVideoFullScreen{
self.hiddenBar = NO;
// 更新状态栏
[self setNeedsStatusBarAppearanceUpdate];
}
- (BOOL)prefersStatusBarHidden {
return self.hiddenBar;
}
!!!注意:同时在info.plist中添加字段View controller-based status bar appearance
, 并取值为YES
时,表示以UIController对状态栏的设置为准,UIApplication对状态栏进行的设置将不起作用。
网友评论