What kind of value is keyTime in an CAKeyFrameAnimation?

后端 未结 2 635
逝去的感伤
逝去的感伤 2021-02-02 03:08

For example I have this CAKeyFrameAnimation:

CALayer* theLayer = myView.layer;
    CAKeyframeAnimation* animation;
    animation = [CAKeyframeAnimation animation         


        
2条回答
  •  伪装坚强ぢ
    2021-02-02 03:50

    The docs are phrased a little oddly here, but are accurate:

    Each value in the array is a floating point number between 0.0 and 1.0 and corresponds to one element in the values array. Each element in the keyTimes array defines the duration of the corresponding keyframe value as a fraction of the total duration of the animation. Each element value must be greater than, or equal to, the previous value.

    Basically, each value indicates at what normalized point in the animation the given keyframe occurs. So if a keyframe is 25% into the animation, the value would be 0.25. The confusing part of the docs is they indicate that it is a duration, when in fact it's a normalized point in time.

提交回复
热议问题