-1

我有三个 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");
    }

但问题是它永远不会打印完成!为什么是这样?

4

1 回答 1

0

您可能想在此处查看有关如何在animationDidStop 委托中识别动画的提示: 如何在animationDidStop 委托中识别CAAnimation?

您确定将自己设置为代表吗?另外,也许 == 不起作用。尝试 isEqualTo: 或上述链接中所述的字符串比较。

于 2012-10-05T21:53:18.290 回答