Jichao Jichao - 3 months ago 21
iOS Question

What's the meaning of progress keypath in CABasicAnimation?

A code snippet from https://github.com/danielamitay/DACircularProgress/blob/master/DACircularProgress/DACircularProgressView.m

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"progress"];
animation.duration = duration;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.fillMode = kCAFillModeForwards;
animation.fromValue = [NSNumber numberWithFloat:self.progress];
animation.toValue = [NSNumber numberWithFloat:pinnedProgress];
animation.beginTime = CACurrentMediaTime() + initialDelay;
animation.delegate = self;
[self.circularProgressLayer addAnimation:animation forKey:@"progress"];

But I could not find
in the offical document. Does the keypath need to be animatable property? What does the


From this answer (which is coincidentally animating progress too):

Firstly we need to create a new subclass of CALayer that has an animatable property called 'progress'.

Your snippet does indeed have a property called 'progress'

@property(nonatomic) CGFloat progress;

It appears the animation is animating that property