我有以下的動畫,我想阻止它,當我按下一個按鈕。你能告訴我我該怎麼做?我無法弄清楚如何。謝謝。
-(void)animationLoop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[UIView beginAnimations:@"Move randomly" context:nil];
[UIView setAnimationDuration:1];
// [UIView setAnimationBeginsFromCurrentState:NO];
CGFloat x = (CGFloat) (arc4random() % (int) self.bounds.size.width);
CGFloat y = (CGFloat) (arc4random() % (int) self.bounds.size.height);
CGPoint squarePostion = CGPointMake(x, y);
strechView.center = squarePostion;
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationLoop:finished:context:)];
[UIView commitAnimations];
}