定义2个动画
-(CAKeyframeAnimation *)moveanimation
{
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL,0,0);
    CGPathAddQuadCurveToPoint(path,NULL, 100, 100, 0, 100);
    CGPathCloseSubpath(path);
    CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
    animation.duration=4.0f;
    animation.path=path;
    animation.calculationMode=kCAAnimationCubicPaced;
    animation.delegate=self;
    CFRelease(path);
    return animation;
}
-(CAKeyframeAnimation *)movestraight
{
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 0, 0);
    CGPathAddLineToPoint(path, NULL, 100, 100);
    CGPathAddLineToPoint(path, NULL, 0, 100);
    CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
    animation.delegate=self;
    animation.duration=4.0f;
    animation.path=path;
    animation.fillMode=kCAFillModeForwards;
    animation.removedOnCompletion=NO;
    CFRelease(path);
    return animation;
}
分别调用他们
[imageView.layer addAnimation:[self movestraight] forKey:@"123"];
[imageView.layer addAnimation:[self moveanimation] forKey:@"234"];
如何再
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
        NSLog(@"123");
}中判断是哪个动画结束了。求详细教育

解决方案 »

  1.   

    when the animation block has finish, you can use
    setAnimationDidStopSelector: method.上API;
    Sets the message to send to the animation delegate when animation stops.
    + (void)setAnimationDidStopSelector:(SEL)selectorIf you are using a CAAnimation instance, look at the animationDidStop:finished: for its delegate.
    your delegate should implement the animation
    DidStop:finished: method to be able to detect the animation end.API如下:
    Called when the animation completes its active duration or is removed from the object it is attached to.
    - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
      

  2.   

    就是说有两个方法,setAnimationDidStopSelector: method 这个方法对于你判断是比较简单好用的。
      

  3.   

    有,你自己考虑考虑先⋯⋯
    http://www.cocoachina.com/bbs/
    搜索一下动画结束⋯⋯
    会有很多
      

  4.   

    将animation.tag随便设为不同值,当回调animationDidStop时判断参数(CAAnimation *)anim的tag就可以知道是哪个动画了
      

  5.   

    用anim指针就可以判断啊; 不可能有两个对象指针完全相同。