I have a tap gesture on a UILabel who\'s translation is being animated. Whenever you tap on the label during the animation there\'s no response from the tap gesture.
<
Below is a more generic answer based on the answer from @agibson007 in Swift 3.
This didn't solve my issue immediately, because I had additional subviews covering my view. If you have trouble, try changing the extension type and writing print statements for touchLocation
to find out when the function is firing. The description in the accepted answer explains the issue well.
extension UIViewController {
open override func touchesBegan(_ touches: Set, with event: UIEvent?) {
guard let touch = touches.first else { return }
let touchLocation = touch.location(in: self.view)
for subview in self.view.subviews {
if subview.tag == VIEW_TAG_HERE && subview.layer.presentation()?.hitTest(touchLocation) != nil {
print("[UIViewController] View Touched!")
// Handle Action Here
}
}
}
}