我在做平移对象后设置动画效果
-(void)panView:(UIPanGestureRecognizer*)recognizer{
//do sth...
if(recogizer.state==UIGestureRecognizerStateEnded){
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut animation^{
//do sth2...
}completion:^(BOOL finished){
//do sth3...
}];
}
}问题是当动画播放的时候,我又把那个物体移过来了。新的摇摄是不会发生的,我应该等到动画完成,这样我可以再次进行摇摄。
我怎么能中断动画突然做新的摇摄?
溶液
将UIViewAnimationOptionAllowUserInteraction添加到选项中。并且可以在重做pan之前设置self.layer removeAllAnimations。
发布于 2013-05-01 08:45:46
试试下面的代码
-(void)panView:(UIPanGestureRecognizer*)recognizer
{
//do sth...
[animatingView.layer removeAllAnimations];
if(recogizer.state==UIGestureRecognizerStateEnded)
{
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction animation^{
//do sth2...
}completion:^(BOOL finished){
//do sth3...
}];
}
}https://stackoverflow.com/questions/15918311
复制相似问题