Sans y compris tous les "trucs" de mon "toolchain", cet exemple n'est pas directement copier/pastable... mais cela montre VRAIMENT facile de la stratégie pour "enchaînés" animations..
CATransform3D trans = m34(); // define chain-wide constants.
// Name your "stack". My "nextObject" returns arr[i]->done == nil.
NSArray *layerStack = layer.sublayers;
//define a block, that "takes" a layer as it's argument.
void(^__block ChainBlock)(CALayer*) = ^(CALayer *m) {
// animations, transforms, etc for each inividual "step".
[m animate:@"transform"
// These are just NSValue-wrapped CAT3D's
from:AZV3d(CATransform3DRotate(trans, 0,1,0,0))
to:AZV3d(CATransform3DRotate(trans,1.5,1,0,0))
time:2 // total time == each step * layerStack.count
eased:kCAMediaTimingFunctionEaseOut
completion:^{ // In completion, look for "next" layer.
CAL* m2 = [layers nextObject];
// If there is "another" layer, call this block, again... with it.
if (m2) chainAnis(m2);
// Otherise,you're done. Cleanup, toggle values, whatevs.
else self.finishedProperty = YES;
}];
};
// Give the block we just defined your "first" layer.
ChainBlock(layerStack[0]); // It will recursively feed itself.
Ceci dépend évidemment de certains "externe de la magie", mais le concept est simple, et élimine (grâce à des dépendances) la nécessité de "faire face à" TOUTE sorte de brute délégation. En particulier, l' animate:from:to:time:easing:completion
, etc. catégories viennent de la grande FunSize Cadre, sur Github.