Setup: I have parent view A. It has a child view B. B is partially inside the bounds of A, but partially outside (A has clipsToBounds=false). I have attached UITapGestureRecognizer (UITGR) to B.
Observed: UITGR fires OK when I tap on the portion of B that is within the bounds of A. UITGR does NOT fire when I tap on the portion of B that is outside the bounds of A.
Expected/question: How do I make UITGR fire when I tap on the portion of B that is outside the bounds of A?
This quote will answer your question as to why it behaves like that:
One workaround is to create your own
UITapInSubviewsViewwith the following definition forhitTest:Then you use this class for your parent view.
(I found this code in a post from S.O. a few weeks ago, but I cannot seem to find it anymore; so just copied it from my project).