Since no one has had a go at answering this and assuming you have not solved it yet, I thought I'd give it a bash.
Firstly I would create a property that stores the state of the animation. ie
NSUIneteger animationState;
which stores:
0 = idleState;
1 = startState;
2 = loopedState;
3 = endState;
I would also create BOOL for determining when to stop the looped animation;
BOOL haltAnimation;
Then, initialise the animationState to 0. When you begin the animation, create the first CAAnimation object and make sure you set the delegate to self. Initialise haltAnimation to false;
In your animationDidStart method (as required by your delegate implementation) have something like this:
-(void)animationDidStart {
switch(animationState) {
case 0:
animationState = 1;
break;
case 1:
animationState = 2;
break;
case 2:
if(haltAnimation)
animationState = 3;
}
}
Then in your animation finished delegate method, do something like this:
-(void)animationDidFinish {
swtich(animationState) {
case 1:
/*apply stage 2 animation and assign delegate to self*/
break;
case 2:
if(!haltAnimation) {
/*apply stage 2 animation and assign delegate to self*/
} else {
/*apply stage 3 animation and assign delegate to self*/
}
break;
case 3:
animationState = 0;
break;
}
}
Then what happens is, stage 2 animation will continue for an arbitrary length until you set haltAnimation to true.
Note that this is all untested and off the cuff. I invite anyone else to offer a better design pattern.