2

如何使用 TapGesture 隐藏/取消隐藏状态栏、标签栏和导航栏。谁能给我它的代码?

4

2 回答 2

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];
}

通过反转值取消隐藏。我希望这有帮助。

于 2013-06-05T12:39:29.123 回答
-1

你想在点击手势上做然后使用

[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(ViewTapped:)]

在你想要实施的观点上。

检查状态栏是否隐藏使用

[[UIApplication sharedApplication] isStatusBarHidden];

然后隐藏状态栏使用:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

并再次显示它使用:

[[UIApplication sharedApplication] setStatusBarHidden:NO];
于 2013-06-05T12:35:01.340 回答