我需要淡入我的 CALayers。这是我的代码:
for(int i = 0; i < viewArray.count; i++)
{
CABasicAnimation *fadeIn = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeIn.duration = 0.3;
fadeIn.beginTime = i;
fadeIn.fromValue = [NSNumber numberWithFloat:0.0];
fadeIn.toValue = [NSNumber numberWithFloat:0.8];
fadeIn.removedOnCompletion = NO;
fadeIn.delegate = self;
[((CALayer*)[viewArray objectAtIndex:i]) addAnimation:fadeIn forKey:nil];
}
但是,只有前两个对象正确褪色,所有其他对象根本不褪色。我注意到,当我在 animationDidStop 处设置断点时,大多数尚未开始的动画已经停止(即使是应该在 60 秒内开始的动画也会在前几秒内停止)。我不确定发生了什么。当我手动将每个 CALayer 的不透明度设置为 1 时,我可以正确看到它,但在制作动画时却看不到。