Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing hitTest logic only for touchesBegan and NOT gesture recognizers
    text
    copied!<p>I have been developing a simple game for iOS which involves dragging and using rotation- and other gesture recognizers. Dragging is realized through <code>touchesBegan/Moved/Ended</code> and rotation - through recognizer.</p> <p>The views are irregularly shaped, and the view borders sometimes overlap, so I implemented Ole Belgeman's <a href="https://github.com/ole/OBShapedButton/tree/master/UIImage+ColorAtPixel" rel="nofollow">UIImage+ColorAtPixel</a> in my <em>picture view</em> and overrode <code>isPointInside</code> method in the main <em>element view</em>. isPointInside invokes the method in <em>picture view</em>, which checks alpha at touch point and returns NO if the transparent section has been touched. Essentially, <code>hitTest</code> ignores this branch.</p> <p>But the side effect of it is that hitTest ignores all touches on the transparent section, and rotation recognizer only works on the non-transparent zone. For some views, which are too small in size, it becomes impossible to use rotation gesture :(</p> <p>Is there any way to somehow avoid this problem and use <code>hitTest</code> logic <strong>only</strong> for <code>touchesBegan</code>? I tried to work the solution out, but it seems that hitTest works strictly before any touch handling. </p> <p>Checking the transparency at <code>touchesBegan</code> works, but when you touch the transparent section, which overlaps the non-transparent section of the other view, the latter doesn't receive the touch.</p> <p>I just can't figure out the trick...</p> <p>Thank you in advance for any help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload