Why using "pan" after rotate makes view go opposite way?
It seems these two gesture are use diffrent coordinate system? Rotation use the one is rotated,and pan use the normal one?
And if the view is rotated nearby 0' or 360 ',pan will be normal,and if the view is rotated more colse to 180',the "pan" will make view go opposite more.
<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/kQWn3.jpg" data-original="https://i.stack.imgur.com/kQWn3.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />Answer1:
The point is that in your
handRotate method you are assigning a rotation transformation to your view. This entails a permanent (until you modify the transformation again) change in the way your view is displayed within its superview, and the rotation transformation will be always "added" to whatever other change you do to the geometrical properties of your view.
What explains the behavior you are seeing is the interplay between the position of your view and its <em>anchor point</em>, as explained in <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layers.html#//apple_ref/doc/uid/TP40006082" rel="nofollow">Layer Geometry and Transform</a>.
In other words, the
center property you are modifying when panning is the result of applying all the transforms that you have defined for your view. On the other hand, what you are trying to do when panning would require modifying the position of the view <em>before</em> the transformation are applied.
A way to go about this is reframing your code by using layers (
CALayer) and modifying the layer
position property instead of the view
center. Like in:
recognizer.view.layer.position = ...
I think that this should fix it.
(You will need to import QuartzCore for that to compile).
Hope this helps.