When exactly do implicit animations take place in iOS?

UIKit disables implicit animations. To be more specific, a CALayer associated with a UIView will never implicitly animate. CALayers that you create yourself and that are not associated with a UIView will buy into the normal implicit animation machinery.

If you’re interested in how this works, implicit animations happen after the normal -actionForKey: lookup. If there’s a CAAction for a given property, it’s used. Otherwise, the implicit animation is used. In the case of a CALayer associated with a UIView, UIView implements the -actionForLayer:forKey: delegate method, and when not in a UIView animation block it always returns [NSNull null] to signify that the action lookup should stop here. This prevents implicit animations from working. Inside of a UIView animation block, it constructs its own action to represent the current UIView animation settings. Again, this prevents implicit animations.

If you need to animate CALayer properties that UIView won’t do for you, you can use an explicit CAAnimation subclass (such as CABasicAnimation).

Leave a Comment