美文网首页
iOS:让超出父视图范围的子视图响应事件,在UIView范围外响

iOS:让超出父视图范围的子视图响应事件,在UIView范围外响

作者: Liu____ | 来源:发表于2020-11-09 18:01 被阅读0次

    https://www.cnblogs.com/WZLpq-home/p/5616309.html[图片上传中...(image.png-88d695-1603266135462-0)]
    //重写该方法后可以让超出父视图范围的子视图响应事件

    • (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
      UIView *view = [super hitTest:point withEvent:event];
      if (view == nil) {
      for (UIView *subView in self.subviews) {
      CGPoint tp = [subView convertPoint:point fromView:self];
      if (CGRectContainsPoint(subView.bounds, tp)) {
      view = subView;
      }
      }
      }
      return view;
      }

    相关文章

      网友评论

          本文标题:iOS:让超出父视图范围的子视图响应事件,在UIView范围外响

          本文链接:https://www.haomeiwen.com/subject/lkhemktx.html