Iphone UIView两个动画共存

Iphone UIView两个动画共存,iphone,objective-c,ios,xcode,cocoa-touch,Iphone,Objective C,Ios,Xcode,Cocoa Touch,调用第二个动画后,如何让一个动画永远继续?例如: 1) 使物体跳动 2) 在它跳动时移动它 3) 它继续跳动 除了第二个动画无限期地停止第一个动画外,其他一切都正常。 下面是一些示例代码: //Pulsate ** [UIView animateWithDuration:0.25 delay:0 options: (UIViewAnimationCurveEase

调用第二个动画后,如何让一个动画永远继续?例如:

1) 使物体跳动 2) 在它跳动时移动它 3) 它继续跳动

除了第二个动画无限期地停止第一个动画外,其他一切都正常。 下面是一些示例代码:

//Pulsate **

        [UIView animateWithDuration:0.25
                              delay:0
                            options: (UIViewAnimationCurveEaseOut | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat)
                         animations:^{
                             CGAffineTransform currentTransform = self.transform;
                             CGAffineTransform newTransform1 = CGAffineTransformScale(currentTransform, .95, .95);
                             [self setTransform:newTransform1];
                             CGAffineTransform newTransform2 = CGAffineTransformScale(currentTransform, 1, 1);
                             [self setTransform:newTransform2];
                         } 
                         completion:nil];    


//Move **
     [UIView animateWithDuration:0.30
                      delay:0
                    options: (UIViewAnimationCurveEaseOut | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState )
                 animations:^{
                     [[(UIPinchGestureRecognizer*)sender view] setCenter:CGPointMake(myAppDelegate.MCViewReference.center.x-300, myAppDelegate.MCViewReference.center.y)];
                 } 
                 completion:^(BOOL finished){
                }];    

您可以将动画分为多个阶段,并使用“完成”块开始下一阶段。

您将无法使用基于块的动画来执行此操作,因为这里有这些动画。您需要使用带有
CABasicAnimation
的显式动画将动画拆分。为脉动效果创建一个动画,并将其设置为无限重复。然后可以通过设置中心(动画或非动画)来移动它

将动画添加到层后,它将开始设置动画。要删除动画,只需调用
[self.layer removeAnimationForKey:@“pulse”
removeanimations:

CABasicAnimation *pulsation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
pulsation.fromValue = [NSNumber numberWithFloat:0.95f];
pulsation.toValue = [NSNumber numberWithFloat:1.f];
pulsation.duration = 0.25f;
pulsation.autoreverses = YES;
pulsation.repeatCount = INFINITY;

[self.layer addAnimation:pulsation forKey:@"pulse"];