Why does UINavigationBar steal touch events?

后端 未结 12 2532
耶瑟儿~
耶瑟儿~ 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:23

    Subclass UINavigationBar and add this method. It will cause taps to be passed through unless they are tapping a subview (such as a button).

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

提交回复
热议问题