#import <UIKit/UIKit.h>
@interface UINavigationBar (Event)
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
@end
#import "UINavigationBar+Event.h"
@implementation UINavigationBar (Event)
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([self pointInside:point withEvent:event]) {
self.userInteractionEnabled = YES;
} else {
self.userInteractionEnabled = NO;
}
return [super hitTest:point withEvent:event];
}
@end
在自定义的UINavigationController中引入头文件 #import "UINavigationBar+Event.h"即可