Reputation: 418
Is it possible to hide a UIToolBar
and UINavigationBar
and to do so with a UITouchGestureRecognizer
but at the same time Expand the UIWebView
so it takes up the rest of the space?
Also to do the same thing in reverse after?
Thanks to all in advance!
Upvotes: 3
Views: 5114
Reputation: 5824
To hide top navigation bar use either the navigationBarHidden
property or setNavigationBarHidden:animated:
method if you want it animated. Similarly, use toolbarHidden
property or setToolbarHidden:animated:
method for the bottom toolbar. These are part of UINavigationController
.
If you want to animate both the toolbars hiding and the UIWebView
expanding, wrap the change in size of the UIWebView
in a UIView animateWithDuration...
method.
Add the gesture recognizer of your choice. For a swipe, create an instance UISwipeGestureRecognizer
and add it to your view. Something like this in your viewDidLoad
method:
UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe)];
[self.view addGestureRecognizer:swipeGestureRecognizer];
And the swipe handler as something like this:
-(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);
}];
}
}
Upvotes: 3
Reputation: 7398
use
-(void)didTap
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
//remove your tool bar from superview
[toolbar removeFromSuperview];
//code to add ur UIWebView
}
Upvotes: 3