Skip to content

Instantly share code, notes, and snippets.

@andreyz
Forked from raulriera/PSPDFTouchForwardingView.swift
Last active December 5, 2017 21:18
Show Gist options
  • Save andreyz/faf4aceeaf0da184f19a093d44b7d14c to your computer and use it in GitHub Desktop.
Save andreyz/faf4aceeaf0da184f19a093d44b7d14c to your computer and use it in GitHub Desktop.
import UIKit
class TouchForwardingView: UIView {
var passthroughViews: [UIView] = []
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
guard let hitView = super.hitTest(point, with: event) else { return nil }
guard hitView == self else { return hitView }
for passthroughView in passthroughViews {
let point = convert(point, to: passthroughView)
if let passthroughHitView = passthroughView.hitTest(point, with: event) {
return passthroughHitView
}
}
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment