首页 > 解决方案 > 让 UIImageView 通过点击查看它背后

问题描述

我有 UICollectionViewCell,其中有一个 100X100 的 UIImageView。我已向 collectionView 单元格内容视图添加了轻击手势。当用户单击图像时,不会调用 tagGesture 方法。任何方式我都可以让 UIImageView 将该手势传递给它后面的 contentView。我不想向 UIImageView 添加另一个点击手势。

标签: iosswiftuitapgesturerecognizer

解决方案


创建这个子类并将其设置为imageView的类名

class TransImgV:UIImageView { 
    override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {  
        return false
    } 
}

推荐阅读