izik461
izik461

Reputation: 1173

Coreplot animations with identifier

I am trying to perform multiple animations in coreplot. To run first animation I've used:

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

and implemented CPTAnimationDelegate:

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

    [self performSecondAnimationWithnewXRange:newXrange];}

I want, however, to run multiple animations using identifier. I've tried creatingPTAnimationOperation, but don't know how to fire it:

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;

How do I actually start the animation, so in delegate I could check it's ID?

Upvotes: 0

Views: 56

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

You can start the second animation the same way you did for the first one. Pass nil for the start value to have the animation begin from the current value of the property. The +animate:property:… methods all return the CPTAnimationOperation so you can set the identifier or have a reference if you might want to cancel it early.

Upvotes: 1

Related Questions