-
-
Save siberian1967/ab1e15f46b5ed30d0e3060079f090ae8 to your computer and use it in GitHub Desktop.
UIView subclass that is transparent to all touch events besides those on eligible child views.
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
import UIKit | |
/** | |
UIView subclass that is transparent to all touch events besides those on eligible child views. | |
*/ | |
class TKPassThroughView: UIView { | |
// MARK - Touch Handling | |
/** | |
Override this point and determine if any of the subviews of our transparent view are the ones being tapped. If that is the case, handle those touches otherwise pass the touch through. | |
*/ | |
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | |
for subview in subviews as [UIView] { | |
if !subview.isHidden && subview.alpha > 0 && subview.isUserInteractionEnabled && subview.point(inside: convert(point, to: subview), with: event) { | |
return true | |
} | |
} | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment