I have a UIView whose backing layer has a CAKeyframeAnimation with a simple straight line set to "path".
Can I make the animation freeze, so to speak, and manually change its progress?
For example: If the path has a length of 100 points, then to set the progress (offset?) To 0.45 it follows that the viewpoint moves 45 points down the path.
I remember seeing an article that did something similar (moving the view along a path based on the value from the slider) through the CAMediaTiming interfaces, but I could not find it even after several hours of searching. If I approach this completely wrong, please let me know. Thank you
Here is an example code if the above is not clear enough.
- (void)setupAnimation { CAKeyFrameAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:_label.layer.position]; [path addLineToPoint:(CGPoint){200, 200}]; animation.path = path.CGPath; animation.duration = 1; animation.autoreverses = NO; animation.removedOnCompletion = NO; animation.speed = 0;
source share