在加载scrollView的类中添加如下代码
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
guard self.point(inside: point, with: event) else {
return super.hitTest(point, with: event)
}
let newPoint = convert(point, to: collectionView)
if collectionView.point(inside: newPoint, with: event) {
for subView in collectionView.visibleCells {
let subViewPoint = convert(point, to: subView)
if subView.point(inside: subViewPoint, with: event) {
return subView
}
}
}
return self
}
网友评论