I have a view that appears as a dialog, and I enliven its opacity when I want it to be removed from the parent view.
I use the following code to change its opacity using CABasicAnimation:
CALayer *opacityOutLayer = sheetView.layer;
CABasicAnimation *fadeOutAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeOutAnimation.fromValue = [NSNumber numberWithFloat:1.0];
fadeOutAnimation.toValue = [NSNumber numberWithFloat:0.0];
fadeOutAnimation.duration = 0.255;
[opacityOutLayer addAnimation:fadeOutAnimation forKey:@"opacity"];
It looks great in the simulator, but not very smooth on the device. Is there a way to cache the animation (e.g. use the transition cache UIView: YES)?
I'm sure this is pretty simple, but after searching for documentation and CALayer class information, I cannot find anything to cache it.
source
share