Animating an image along a path to a specified position using CAKeyFrameAnimation

What I'm trying to achieve is the ability to animate and position an image along a path at a specific location along the path. The percentage along the way will be good.

What I want to achieve:

Current Location of Image Along the PathNew position long the path

What happens when I install an animation, it animates all the way, back to the starting point. I need to know how to specify a breakpoint anywhere in the way.

Below is a snippet:

imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EMOTICON_0.png"]]; [view addSubview:imageView]; CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; positionAnimation.path = [view path].CGPath; positionAnimation.rotationMode = kCAAnimationRotateAuto; positionAnimation.removedOnCompletion = NO; positionAnimation.fillMode = kCAFillModeForwards; positionAnimation.duration = 5.0; positionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [imageView.layer addAnimation:positionAnimation forKey:positionAnimation.keyPath]; 
+4
source share

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


All Articles