I'd still like to hear others suggestions but I think I've solved this.
I'm now creating specific CAAnimation
objects and specifying their beginTime
property. I was doing this earlier and it wasn't working, what I finally realized is that for the beginTime
property to be honored the animation has to be added to an CAAnimationGroup
.
So, my code looks like this:
NSArray *layers = /* layers to be animated away */
CGFloat startOffset = 0.01;
for (NSInteger index = 0; index < layers.count; index++) {
CALayer *layer = [layers objectAtIndex:index];
CABasicAnimation *zoomOut = [CABasicAnimation animationWithKeyPath:@"zPosition"];
zoomOut.toValue = [NSNumber numberWithDouble:400.0];
zoomOut.beginTime = index * startOffset;
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = [NSArray arrayWithObject:zoomOut];
group.delegate = self;
[layer addAnimation:group forKey:@"zoomAway"];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…