To do this, you need to subclass UINavigationBar, redefine the init button in it and add your gesture recognizer there.
So, say that you are creating a subclass of "CustomNavigationBar" - in your m file you will have an init method like this:
- (id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { UISwipeGestureRecognizer *swipeRight; swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)]; [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; [swipeRight setNumberOfTouchesRequired:1]; [swipeRight setEnabled:YES]; [self addGestureRecognizer:swipeRight]; } return self; }
Then you need to set the class name of your navigation bar in the interface builder for the name of your subclass.

Itβs also convenient to add a delegate protocol to the navigation bar to listen for methods sent at the end of your gestures. For example - in the case of the above, swipe right:
@protocol CustomNavigationbarDelegate <NSObject> - (void)customNavBarDidFinishSwipeRight; @end
then in the m file - in the recognized gesture method (no matter what you do) you can call this delegate method.
Hope this helps
source share