Last active
March 4, 2019 16:02
-
-
Save diegoperini/8dfa345fca7c733c411dbec6e93729b0 to your computer and use it in GitHub Desktop.
A parent view to redirect touch events to its first child, can be used to extend scrollable area of a small UIScrollView
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
// Make sure you disable user interractions on the first child of this view | |
class TouchProxyView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
} | |
override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? { | |
let v = super.hitTest(point, withEvent: event) | |
if v == self { | |
if let c = v?.subviews.first { | |
return c | |
} | |
} | |
return v | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swift 4.2