Skip to content

Instantly share code, notes, and snippets.

@kharmabum
Last active July 20, 2016 15:17
Show Gist options
  • Save kharmabum/10667020 to your computer and use it in GitHub Desktop.
Save kharmabum/10667020 to your computer and use it in GitHub Desktop.
Tappable title view UINavigationBar
#pragma mark - UIGestureRecognizerDelegate
// Toggle mode through touch gesture on navigation bar
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return (self.navigationController.visibleViewController == self &&
(ABS([touch locationInView:self.navigationController.navigationBar].x - self.navigationController.navigationBar.width/2) < 50));
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController.navigationBar addGestureRecognizer:self.tapGestureRecognizer];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar removeGestureRecognizer:self.tapGestureRecognizer];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment