带有标识符的Coreplot动画

时间:2016-03-03 18:29:28

标签: ios animation core-plot

我正在尝试在coreplot中执行多个动画。 要运行我使用的第一个动画:

 [CPTAnimation animate:plotSpace
                 property:@"xRange"
            fromPlotRange:oldXrange
              toPlotRange:newxRange
                 duration:1.0
                withDelay:0
           animationCurve:CPTAnimationCurveCubicInOut
                 delegate:self];

并实施了CPTAnimationDelegate

-(void)animationDidFinish:(nonnull CPTAnimationOperation *)operation {
    CPTPlotRange *newxRange = [CPTPlotRange
                               plotRangeWithLocation:@500
                               length:@100];

    [self performSecondAnimationWithnewXRange:newXrange];}

但是,我希望使用标识符运行多个动画。我尝试过创建PTAnimationOperation,但不知道如何解雇它:

CPTAnimationOperation* animation1 = [[CPTAnimationOperation alloc] init];
CPTAnimationPeriod *period = [CPTAnimationPeriod periodWithStartPlotRange:plotSpace.xRange
                                                                         endPlotRange:newxRange
                                                                             duration:3.0
                                                                            withDelay:0.0];
animation1.identifier = @"animation1ID";
animation1.period = period;

如何实际启动动画,所以在委托中我可以查看它的ID?

1 个答案:

答案 0 :(得分:1)

您可以像第一个动画一样开始第二个动画。传递nil作为起始值,以使动画从属性的当前值开始。 +animate:property:…方法都返回CPTAnimationOperation,因此您可以设置identifier或者如果您想提前取消它,请提供参考。