IPhone / iPad Spinner for saving animation

I am new to core-animation. I base this on a previous post: rotate the image clockwise / counterclockwise when touched

Probably the main question, but I just want the circle to rotate at a certain distance, and then stop. When the animation ends, it returns to its original location.

How to save an element in the place where it ends when the animation ends?


What I really want is a free floating wheel that responds to user scrolling. When the user turns left on the wheel, the wheel rotates left. Depending on the scroll speed, the wheel spins faster and then starts to slow down. If someone can give some hints or directions about this, I would be very grateful. alt text

+3
source share
2 answers

Core Animation. A CAAnimation "" . . , toValue , . . , , . :

CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform"];
rotate.fromValue = [NSValue valueWithCATransform3D:myLayer.transform];
rotate.toValue = [NSValue valueWithCATransform3D:CATransform3DRotate(myLayer.transform, M_PI, 0.f, 0.f, 1.f)];
rotate.duration = .5f;

myLayer.transform = CATransform3DRotate(myLayer.transform, M_PI, 0.f, 0.f, 1.f);
[myLayer addAnimation:rotate forKey:@"transform"];

addAnimation:forKey:. . a CALayer , , , /.

, , , UIPanGestureRecognizer, . velocityInView:, 2D- , . github, .

+3

Source: https://habr.com/ru/post/1783650/


All Articles