iphone动画结束问题

lilovingli0928 2011-07-13 10:55:31
定义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");
}中判断是哪个动画结束了。求详细教育

...全文
524 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
程序员小迷 2012-01-14
  • 打赏
  • 举报
回复
另外,1楼的同样可以。
程序员小迷 2012-01-14
  • 打赏
  • 举报
回复
用anim指针就可以判断啊; 不可能有两个对象指针完全相同。
咸清 2011-07-13
  • 打赏
  • 举报
回复
有,你自己考虑考虑先⋯⋯
http://www.cocoachina.com/bbs/
搜索一下动画结束⋯⋯
会有很多
lilovingli0928 2011-07-13
  • 打赏
  • 举报
回复
有没有实际的例子饿。
咸清 2011-07-13
  • 打赏
  • 举报
回复
就是说有两个方法,setAnimationDidStopSelector: method 这个方法对于你判断是比较简单好用的。
咸清 2011-07-13
  • 打赏
  • 举报
回复
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)selector

If 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
melody1304 2011-07-13
  • 打赏
  • 举报
回复
将animation.tag随便设为不同值,当回调animationDidStop时判断参数(CAAnimation *)anim的tag就可以知道是哪个动画了

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧