是否可以隐藏 a UIToolBar
andUINavigationBar
并用 a 这样做UITouchGestureRecognizer
但同时展开 theUIWebView
以占用其余空间?还反过来做同样的事情?
提前感谢大家!
是否可以隐藏 a UIToolBar
andUINavigationBar
并用 a 这样做UITouchGestureRecognizer
但同时展开 theUIWebView
以占用其余空间?还反过来做同样的事情?
提前感谢大家!
要隐藏顶部导航栏,请使用navigationBarHidden
属性或setNavigationBarHidden:animated:
方法(如果您希望它具有动画效果)。同样,使用底部工具栏的toolbarHidden
属性或setToolbarHidden:animated:
方法。这些是UINavigationController
.
如果您想为工具栏隐藏和UIWebView
扩展设置动画,请将大小的更改包装UIWebView
在一个UIView animateWithDuration...
方法中。
添加您选择的手势识别器。对于滑动,创建一个实例UISwipeGestureRecognizer
并将其添加到您的视图中。在你的viewDidLoad
方法中是这样的:
UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe)];
[self.view addGestureRecognizer:swipeGestureRecognizer];
滑动处理程序如下所示:
-(void)handleSwipe{
if (self.navigationController.navigationBarHidden) {
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setToolbarHidden:NO animated:YES];
[UIView animateWithDuration:0.3 animations:^{
self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, self.webView.frame.size.height - 88);
}];
} else {
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:YES animated:YES];
[UIView animateWithDuration:0.3 animations:^{
self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, self.webView.frame.size.height + 88);
}];
}
}
采用
-(void)didTap
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
//remove your tool bar from superview
[toolbar removeFromSuperview];
//code to add ur UIWebView
}