Why does UINavigationBar steal touch events?

后端 未结 12 2521
耶瑟儿~
耶瑟儿~ 2020-11-27 18:48

I have a custom UIButton with UILabel added as subview. Button perform given selector only when I touch it about 15points lower of top bound. And when I tap above that area

12条回答
  •  情深已故
    2020-11-27 19:09

    Give a extension version according to Bart Whiteley. No need to subclass.

    @implementation UINavigationBar(Xxxxxx)
    
    - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        UIView *v = [super hitTest:point withEvent:event];
        return v == self ? nil: v;
    }
    
    @end
    

提交回复
热议问题