Created
October 24, 2023 08:23
-
-
Save danielgarbien/3cb1aa3545a17e71cc165703429c6d61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TouchGoThroughView: UIView { | |
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | |
super.point(inside: point, with: event) && pointInsideVisibleSubviews(point, with: event) | |
} | |
} | |
extension UIView { | |
func pointInsideVisibleSubviews(_ point: CGPoint, with event: UIEvent?) -> Bool { | |
let visibleSubviews = subviews.filter { | |
$0.isHidden == false && $0.alpha > 0 | |
} | |
for subview in visibleSubviews { | |
let pointInSubview = convert(point, to: subview) | |
if subview.point(inside: pointInSubview, with: event) { | |
return true | |
} | |
} | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment