定义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");
}中判断是哪个动画结束了。求详细教育
-(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");
}中判断是哪个动画结束了。求详细教育
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
http://www.cocoachina.com/bbs/
搜索一下动画结束⋯⋯
会有很多