I'm looking for a way to pass touches from a clear ViewController that is on top of another ViewController. I came across the following post already:
How to ignore touch events and pass them to another subview's UIControl objects?
I followed their tips but couldn't get it to work unfortunately.
I got the following view structure from top to bottom:
VideoViewController (note: clear ViewController can see the buttons underneath)
| passThroughView (note: UIView that is using the PassThroughView subclass)
| collectionView
CameraViewController
| controlContainer
| | recordButton
When tapping outside the collectionview and on the recordbutton which is behind the passThroughView it should execute a new record. Problem is that with the following code I can't make that happen:
class PassThroughView: UIView {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let hitView = super.hitTest(point, with: event)!
let cameraVC = CameraViewController()
if hitView == self {
return cameraVC.recordButton
}
return hitView
}
}
As soon as my passThroughView gets tapped I get a print in the if statement but it doesn't return my touch to the other ViewControllers button.
So what am I doing wrong here?