gpt4 book ai didi

iphone - CAKeyFrameAnimation 中的 keyTime 是什么样的值?

转载 作者:行者123 更新时间:2023-12-03 18:34:45 25 4
gpt4 key购买 nike

例如,我有这个 CAKeyFrameAnimation:

CALayer* theLayer = myView.layer;
CAKeyframeAnimation* animation;
animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];

animation.duration = 1.6;
//animation.cumulative = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;

animation.values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0 * M_PI],
[NSNumber numberWithFloat:(15.0/180.0) * M_PI],
[NSNumber numberWithFloat:(30.0/180.0) * M_PI], // animation stops here...
[NSNumber numberWithFloat:(45.0/180.0) * M_PI], // ignored!
[NSNumber numberWithFloat:(190.0/180.0) * M_PI], nil]; // ignored!

animation.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.2],
[NSNumber numberWithFloat:0.4], // ignored!
[NSNumber numberWithFloat:0.8], // ignored!
[NSNumber numberWithFloat:1.6], nil]; // ignored!

animation.timingFunctions = [NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], nil];

[theLayer addAnimation:animation forKey:@"transform.rotation.z"];

我不明白的是:

A) 关键时间值是自动画开始以来的绝对耗时吗?

B) 关键时间值只是说明该特定关键帧要使用多少时间?

最佳答案

docs这里的措辞有点奇怪,但很准确:

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.

基本上,每个值都指示给定关键帧发生在动画中的哪个标准化点。因此,如果关键帧占动画的 25%,则该值将为 0.25。文档中令人困惑的部分是它们表明它是一个持续时间,而实际上它是一个标准化的时间点。

关于iphone - CAKeyFrameAnimation 中的 keyTime 是什么样的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2184803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com