Timing is an important part of animations, and with Core Animation you specify precise timing information for your animations through the methods and properties of the
CAMediaTiming
protocol. Two Core Animation classes adopt this protocol. TheCAAnimation
class adopts it so that you can specify timing information in your animation objects. TheCALayer
also adopts it so that you can configure some timing-related features for your implicit animations, although the implicit transaction object that wraps those animations usually provides default timing information that takes precedence.When thinking about timing and animations, it is important to understand how layer objects work with time. Each layer has its own local time that it uses to manage animation timing. Normally, the local time of two different layers is close enough that you could specify the same time values for each and the user might not notice anything. However, the local time of a layer can be modified by its parent layers or by its own timing parameters. For example, changing the layer’s
speed
property causes the duration of animations on that layer (and its sublayers) to change proportionally.
时间是动画中很重要的一个概念,我们可以通过CAMediaTiming协议提供的属性来控制动画的时间相关内容。
@interface CAAnimation : NSObject <NSSecureCoding, NSCopying, CAMediaTiming, CAAction>
@interface CALayer : NSObject <NSSecureCoding, CAMediaTiming>
CAAnimation遵守了该协议,我们可以使用该协议指定创建动画中的时间信息。
CALayer也遵守了该协议,隐式动画自动包装了默认时间信息以供使用,我们可以通过这个方式控制隐式动画的时间相关特性。