

If you fix the animation delegate and try something like: - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag So, when you fix fillMode to kCAFillModeForwards and removedOnCompletion to NO, you let the animation remains in the layer. SomeLayer.opacity = 1 // <- important, this is the state you want visible after the animation finishes.įinally, if you use 'removedOnCompletion = false' it'll leak CAAnimations until the layer is eventually disposed - Godwin's answer is not really good, " = 1 " is done immediately (it takes about one second), please fix alphaAnimation.duration to 10.0, if you have doubts.

If you want to have a delay, do the following: let animation = CABasicAnimation(keyPath: "opacity")Īnimation.beginTime = nvertTime(CACurrentMediaTime(), fromLayer: nil) + 1Īnimation.fillMode = kCAFillModeBackwards // So the opacity is 0 while the animation waits to start. Do this on the line before you add the animation to avoid a flicker when it completes. So set the opacity (or whatever) to what you want to be seen when the animation finishes and the presentation layer goes away. SomeLayer.addAnimation(animation, forKey: "myAnimation")Ĭore animation shows a 'presentation layer' atop your normal layer during the animation. SomeLayer.opacity = 1 // important, this is the state you want visible after the animation finishes. This works: let animation = CABasicAnimation(keyPath: "opacity")

= 1 ĬABasicAnimation *animation = [CABasicAnimation = 0 So it would be a better solution to update the property directly on the model layer to the final value. In addition, the model layer and the presentation layer won't be synchronous any more, which may lead to potential bugs. Simply setting removedOnCompletion to NO means the animation won't be removed and wastes memory.

Then the presentation layer falls back to the value of the model layer. By default, the animation is removed once the it's completed. When the animation is in progress, the model layer is actually intact and keeps it initial value. Core animation maintains two layer hierarchies: the model layer and the presentation layer.
