Created
May 3, 2016 10:24
-
-
Save raulriera/43dfd76a72d4ecb07a67510fb3f5d3c9 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 | |
// This class allows the "presentedController" to receive touches | |
// https://pspdfkit.com/blog/2015/presentation-controllers/ | |
class PSPDFTouchForwardingView: UIView { | |
var passthroughViews: [UIView] = [] | |
override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? { | |
guard let hitView = super.hitTest(point, withEvent: event) else { return nil } | |
guard hitView == self else { return hitView } | |
for passthroughView in passthroughViews { | |
let point = convertPoint(point, toView: passthroughView) | |
if let passthroughHitView = passthroughView.hitTest(point, withEvent: event) { | |
return passthroughHitView | |
} | |
} | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for that!
Swift
syntax is a bit outdated though, here is the up-to-date 5 version as of October 2021.