父View禁用touch 如何让子view还能获取touch event


如上图 当view2 包含在view1中,默认清空下 view1 的touch事件被禁用掉侯view2 肯定是接收不到touch事件的,那有没有什么办法能够让view2接收到touch事件呢?
其实很简单hitTest 可以帮我们实现这个需求

uiview addition
-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    id hitView = [super hitTest:point withEvent:event];
    if (hitView == self) return nil;
    else return hitView;
}


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2021-10-26
相关资源
相似解决方案