In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.
As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.
In order to implement the UIView
transactional animation blocks, UIView
disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey:
method.
Somewhat strangely, UIView
doesn't enable animations for every property that CALayer
does by default. A notable example is the layer.contents
property, which is animatable by default for a hosted layer, but cannot be animated using a UIView
animation block.