Forked from raulriera/PSPDFTouchForwardingView.swift
Last active
December 5, 2017 21:18
-
-
Save andreyz/faf4aceeaf0da184f19a093d44b7d14c 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
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