Skip to content

Instantly share code, notes, and snippets.

@yoxisem544
Last active June 19, 2017 12:24
Show Gist options
  • Save yoxisem544/81ee8f0b32cec5fc83c70749f0c24e19 to your computer and use it in GitHub Desktop.
Save yoxisem544/81ee8f0b32cec5fc83c70749f0c24e19 to your computer and use it in GitHub Desktop.
import UIKit
final public class HitTestExtendedView: UIView {
public weak var reciever: UIView?
public convenience init(withWidth: CGFloat, andRecieverView r: UIView?) {
self.init(frame: CGRect(origin: CGPoint.zero, size: CGSize(width: withWidth, height: withWidth)))
self.reciever = r
}
fileprivate override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
return (self.point(inside: point, with: event) ? reciever : nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment