相关疑难解决方法(0)

取消UIView动画?

是否可以在UIView动画进行过程中取消动画?或者我是否必须降至CA级别?

即我已经完成了这样的事情(也可能设置一个结束动画动作):

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
// other animation properties

// set view properties

[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

但是在动画完成之前我得到动画结束事件,我想取消它(剪短它).这可能吗?谷歌搜索周围发现一些人问同样的问题没有答案 - 一两个人推测它不能完成.

core-animation uiviewanimation ios

243
推荐指数
10
解决办法
15万
查看次数

如何取消UIView基于块的动画?

我搜索了很多SO的东西和Apple的参考资料,但仍然无法解决我的问题.

是)我有的:

  1. 屏幕与2 UIImageViews nad连接2 UIButtons
  2. 2种动画:
    2.1.第一个是向上扩展,然后在viewDidLoad 2.2中一个接一个地向下移动每个图像.第二个,当按下按钮(这是自定义按钮,隐藏在每个UIImageView的'内部')时,它会触发相应UIImageView的动画 - 只有一个,而不是两个 - (也可以向上扩展,然后向下).
  3. 当我为iOS4 +写作时,我被告知要使用基于块的动画!

我需要的:

如何取消正在运行的动画?除了最后一个,我设法取消了...:/这是我的代码片段:

[UIImageView animateWithDuration:2.0 
                               delay:0.1 
                             options:UIViewAnimationOptionAllowUserInteraction 
                          animations:^{
        isAnimating = YES;
        self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 2.0, 2.0);
    } completion:^(BOOL finished){
        if(! finished) return;
        [UIImageView animateWithDuration:2.0 
                                   delay:0.0 
                                 options:UIViewAnimationOptionAllowUserInteraction 
                              animations:^{
            self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 0.5, 0.5);
        } completion:^(BOOL finished){
            if(! finished) return;
            [UIImageView animateWithDuration:2.0 
                                       delay:0.0 
                                     options:UIViewAnimationOptionAllowUserInteraction 
                                  animations:^{
                self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 2.0, 2.0);
            } completion:^(BOOL finished){
                if(! finished) return;
                [UIImageView animateWithDuration:2.0 
                                           delay:0.0 
                                         options:UIViewAnimationOptionAllowUserInteraction 
                                      animations:^{
                    self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 0.5, 0.5);
                }
                                      completion:^(BOOL …
Run Code Online (Sandbox Code Playgroud)

iphone animation uiimageview ios4 ios

74
推荐指数
2
解决办法
5万
查看次数