I'm new to Core Animations, I want to fade out two different layers one after another.I write them in a CATransaction block. I wonder if there is better approach to make such animations.
[CATransaction begin];
CABasicAnimation *fadeOutLoadingBar = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeOutLoadingBar.fromValue = [NSNumber numberWithFloat:0.3];
fadeOutLoadingBar.toValue = [NSNumber numberWithFloat:0.];
fadeOutLoadingBar.fillMode = kCAFillModeForwards;
fadeOutLoadingBar.beginTime = [_loadingLayer convertTime:CACurrentMediaTime() fromLayer:nil];
fadeOutLoadingBar.duration = .8;
fadeOutLoadingBar.removedOnCompletion = NO;
[_loadingLayer addAnimation:fadeOutLoadingBar forKey:nil];
[self setupCheckMarkLayer]; //initialize _checkMarkLayer
CABasicAnimation *fadeOutCheckMark = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeOutCheckMark.fromValue = [NSNumber numberWithFloat:0.3];
fadeOutCheckMark.toValue = [NSNumber numberWithFloat:0.];
fadeOutCheckMark.fillMode = kCAFillModeForwards;
fadeOutCheckMark.beginTime = [_checkMarkLayer convertTime:CACurrentMediaTime() fromLayer:nil] + 0.5;
fadeOutCheckMark.duration = 1.0;
fadeOutCheckMark.removedOnCompletion = NO;
_checkMarkLayer.opacity = 0.;
[_checkMarkLayer addAnimation:fadeOutCheckMark forKey:nil];
[CATransaction setCompletionBlock:^{
self.userInteractionEnabled = YES;
[self.delegate finishedLoading];
[self setupLoadingLayer];
}];
[CATransaction commit];
[NSNumber numberWithFloat:0.]
actually work? \$\endgroup\$