我有三个 CAShapeLayer,每个都有不同的路径,但是三个图层应用了相同的动画,即:
[self animateToLineLayer:self.leftDottedLine_ withKey:@"leftLineAnimated"];
- (void) animateToLineLayer:(CAShapeLayer *) line withKey:(NSString *) key
{
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
[pathAnimation setFromValue:[NSNumber numberWithFloat:0.0f]];
[pathAnimation setToValue:[NSNumber numberWithFloat:1.0f]];
[pathAnimation setDuration:10.0];
[pathAnimation setDelegate:self];
[pathAnimation setFillMode:kCAFillModeForwards];
[line addAnimation:pathAnimation forKey:key];
}
then I try to find this animation back by doing:
- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag
{
if (animation == [self.leftDottedLine_ animationForKey:@"strokeEnd"]) {
NSLog(@"DONE");
}
if (![self.leftDottedLine_ isNotNull]){
NSLog(@"NIL");
}
NSLog(@"JUST DONE");
}
但问题是它永远不会打印完成!为什么是这样?