首页 > 移动平台 > 详细

实现 iOS UICollectionView的事件透传

时间:2019-09-06 12:38:16      阅读:106      评论:0      收藏:0      [点我收藏+]

比如当前的collectionViewA(蓝色), 还有一个collectionViewCellA(红色),collectionViewCellA(红色)里面有一个collectionViewB(绿色),

collectionViewCellB(绿色)里面有两个collectionViewCellB1(白色)、collectionViewCellB2(白色)

技术分享图片

 

点击collectionViewCellA(红色) 弹出点击collectViewAcell

点击collectionViewB(绿色) 也弹出点击collectViewAcell 

点击collectionViewCellB1(白色)、collectionViewCellB2(白色) 弹出点击collectViewBcell

 

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    CGPoint btnPointInA = [self.collectView convertPoint:point fromView:self];
    if ([self.collectView pointInside:btnPointInA withEvent:event]) {
        for (UIView *subView in self.collectView.subviews) {
            CGPoint subViewPoint = [subView convertPoint:point fromView:self];
            if ([subView pointInside:subViewPoint withEvent:event]) {
                return subView;
            }
        return self;
    }
    // 否则,返回默认处理
    return [super hitTest:point withEvent:event];
}

实现 iOS UICollectionView的事件透传

原文:https://www.cnblogs.com/xilanglang/p/11474102.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!