flashlib
4/14/2014 - 5:21 PM

Tappable title view UINavigationBar

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