2: CAKeyframeAnimation, cakeyframeanimation
It is a subclass of CApropertyAnimation. The difference with CABasicAnimation is that CABasicAnimation can only be changed from one value (fromValue) to another value (toValue), and CAKeyframeAnimation will use an NSArray to save these values, A CALayer attribute can be animated based on a string of values, just like a frame-by-frame animation.
Several key attributes:
- Values:Is the above NSArray object. The elements are called "key frames" (keyframe ). The animation object will display each key frame in the values array in sequence within the specified time (duration)
- Path:Set a CGPathRef \ CGMutablePathRef path object. By default, nil is used to move CALayer to the path. Path only applies to the anchorPoint and position of CALayer. If you set path, values will be ignored.
- KeyTimes:You can specify a time point for the key frame. The value range is 0 to 1.0. Each time value in keyTimes corresponds to each frame in values. when keyTimes is not set, the time of each key frame is equally divided.
Note: CABasicAnimation can be viewed as a CAKeyframeAnimation with a maximum of two key frames.