我正在做一些使用块级技术的动画。我想根据一定的条件停止动画。我将如何阻止动画完成?如何停止正在运行的动画
以下是我的动画代码:
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>0)
vwb1.center = CGPointMake(260, 40);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>1)
vwb2.center = CGPointMake(260, 100);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>2)
vwb3.center = CGPointMake(260, 160);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
if([arrAns count]>3)
vwb4.center = CGPointMake(260, 220);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
if([arrAns count]>4)
vwb5.center = CGPointMake(260, 280);
} completion:nil];
}];
}];
}
];
}];
我没有任何这里的关键,所以我可以n不是将其删除一个关键的基础上。还有一个功能是removeallanimation,但我无法使用它。如果有人能够帮助我如何使用它,它也会很好。
编辑:好吧,我想通了,如何做到这一点,我使用下面的代码做它:
[self.view.layer removeAllAnimations];
但现在我有问题尚未开始了我的块级动画仍在运行。所以如果我在第二个块中删除动画,它仍然会执行剩余的块。我也需要阻止它。
感谢
潘卡
你试过removeallanimations? –
@Praveen现在请检查我的信息。我有更新... – pankaj
你必须单独停止所有图层的动画。 –