Jichao Jichao - 1 year ago 86
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
progress
in the offical document. Does the keypath need to be animatable property? What does the
progress
mean?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download