Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 带有UIViewAnimationOptionRepeat的动画不重复_Ios_Cocoa Touch_Uiview_Uiviewanimation - Fatal编程技术网

Ios 带有UIViewAnimationOptionRepeat的动画不重复

Ios 带有UIViewAnimationOptionRepeat的动画不重复,ios,cocoa-touch,uiview,uiviewanimation,Ios,Cocoa Touch,Uiview,Uiviewanimation,我有一段代码,应该循环动画,直到它运行到另一个形状。但是,它只运行一次,不执行任何后续操作。您正在使用CoreAnimation对象,将不受UIView动画块的影响,请删除UIView动画块并添加: [UIView animateWithDuration:speedOfCutout delay:0.2f options:UIViewAnimationCurveEaseInOut | UIViewAnimation

我有一段代码,应该循环动画,直到它运行到另一个形状。但是,它只运行一次,不执行任何后续操作。

您正在使用CoreAnimation对象,将不受UIView动画块的影响,请删除UIView动画块并添加:

[UIView animateWithDuration:speedOfCutout
                      delay:0.2f
                    options:UIViewAnimationCurveEaseInOut | UIViewAnimationOptionRepeat //| UIViewAnimationOptionAutoreverse
                 animations:^{

                     CABasicAnimation *animation = [CABasicAnimation animation];
                     animation.keyPath = @"position.y";
                     animation.fromValue = @77;
                     animation.toValue = @600;
                     animation.duration = speedOfCutout;

                     [cutout.layer addAnimation:animation forKey: @"basic"];
                     cutout.layer.position = CGPointMake(160, 61);
                     [cutout.layer addAnimation:animation forKey: @"basic"];
                     cutout.layer.position = CGPointMake(160, 61);

                     [cutout.layer addAnimation:animation forKey: @"basic"];
                     cutout.layer.position = CGPointMake(160, 61);

                 }
                 completion:^(BOOL fin) {
                 }];

if (CGRectIntersectsRect(cutout.frame, shape.frame)) {
    cutout.hidden = YES;
    shape.hidden = YES;

    [cutoutMovementTimer invalidate];

    [self gameOver];

}
会有用的。

试试这个: 设置animation.repeatCount=-1;
完成块是否处理形状更改事件并停止动画。

可能是因为第一个选项不是选项,所以忽略了所有选项,所以它不起作用。我想应该是UIViewAnimationOptionCurveEaseInOut
animation.autoreverses = YES;
animation.repeatCount = HUGE_VAL;