Iphone 触摸按钮时重新启动动画
我需要在单击按钮时重新启动动画 这是“我的动画”的代码:Iphone 触摸按钮时重新启动动画,iphone,cocoa-touch,animation,uiimageview,Iphone,Cocoa Touch,Animation,Uiimageview,我需要在单击按钮时重新启动动画 这是“我的动画”的代码: imgStar.frame = CGRectMake(205, 6, imgStar.frame.size.width, imgStar.frame.size.height); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.5]; [UIView setAnimationDelegate:self]; [U
imgStar.frame = CGRectMake(205, 6, imgStar.frame.size.width, imgStar.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
imgStar.transform = CGAffineTransformMakeTranslation(-4, 340);
[UIView commitAnimations];
问题是:当我再次单击我的按钮时,动画不起作用
你能帮帮我吗?我发现了问题。
错误是imgStar.transform。我尝试使用以下代码:
[imgStar setFrame:CGRectOffset([imgStar frame], -4, 340)];
而不是
imgStar.transform = CGAffineTransformMakeTranslation(-4, 340);
现在它工作了 为什么第二次的动画不起作用?