如何使用TapGesture隐藏/取消隐藏状态栏,标签栏和导航栏。 任何人都可以给我代码吗?
答案 0 :(得分:1)
向视图添加点按手势
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideUIComponents:)];
[self.view addGestureRecognizer:tapGestureRecognizer];
然后是函数hideUIComponents
- (void)hideUIComponents:(UITapGestureRecognizer*)tapGesture
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[[self navigationController] setNavigationBarHidden:YES animated:YES];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionMoveIn];
[[self.view.window layer] addAnimation:animation forKey:@"layerAnimation"];
[self.tabBarController.tabBar setHidden:YES];
}
通过反转值取消隐藏。我希望这会有所帮助。
答案 1 :(得分:-1)
你想要点击手势 然后使用
[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(ViewTapped:)]
在您要实施的位置的视图上。
使用
检查状态栏是否隐藏[[UIApplication sharedApplication] isStatusBarHidden];
然后 隐藏状态栏使用:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
并再次显示使用:
[[UIApplication sharedApplication] setStatusBarHidden:NO];