Skip to content

Instantly share code, notes, and snippets.

@hlung
Last active May 10, 2022 01:45
Show Gist options
  • Save hlung/b65b50a61e568e9c967a6379573dec29 to your computer and use it in GitHub Desktop.
Save hlung/b65b50a61e568e9c967a6379573dec29 to your computer and use it in GitHub Desktop.
// Put this in a UITableViewCell or UICollectionViewCell subclass.
// Returns nil if point is not within the specified subviews.
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let subviews = [imageView, titleLabel, detailLabel, downloadButton]
for view in subviews {
if view.convert(view.bounds, to: self).contains(point) {
return super.hitTest(point, with: event)
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment