CAKeyframeAnimation:tensionValues 属性
tensionValues 属性调整平滑曲线在每个关键帧值附近的松紧。只在 calculationMode 是 'cubic' 或 'cubicPaced' 时有效。
值
数的数组,或者 null。每项对应 values 里的一个值,取值 −1 到 1,没有单位。
- 可读,可写。
- 默认值是
null。没给的项按 0 算。 - 效果未在模拟器验证。
写错时
抛 TypeError:
- 不是数组也不是
null:tensionValues must be an array of numbers or null, got … - 某一项转换不出有限数:
tensionValues[0] must be a finite number, got …
示例
js
const wave = CAKeyframeAnimation.animationWithKeyPath('position');
wave.values = [new CGPoint(30, 80), new CGPoint(150, 20), new CGPoint(270, 80)];
wave.calculationMode = 'cubic';
wave.tensionValues = [0, 0.5, 0];
console.log((wave.tensionValues || []).join(','));结果:控制台输出 0,0.5,0。中间那个值附近曲线的松紧改变。画面上的表现未在模拟器验证。
对应的 iOS API
CAKeyframeAnimation.tensionValues。