当前位置 : 主页 > 手机开发 > 其它 >

swift3 – 带#keyPath的CATransform3D密钥路径

来源:互联网 收集:自由互联 发布时间:2021-06-11
是否可以使用增强的密钥路径(如 here所述)为Swift 3中的CATransform3D属性添加新的#keyPath关键字? 换句话说就是替换 let scaleAnimation = CABasicAnimation(keyPath: "transform.scale") 喜欢的东西 let scaleA
是否可以使用增强的密钥路径(如 here所述)为Swift 3中的CATransform3D属性添加新的#keyPath关键字?

换句话说就是替换

let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")

喜欢的东西

let scaleAnimation = CABasicAnimation(keyPath:  #keyPath(CALayer.transform.???))
应该使用CAValueFunction.

let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")

– >

let scaleAnimation = CABasicAnimation(keyPath: #keyPath(CALayer.transform))
scaleAnimation.valueFunction = CAValueFunction(name: kCAValueFunctionScale)

let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation")

– >

let rotationAnimation = CABasicAnimation(keyPath: #keyPath(CALayer.transform))
rotationAnimation.valueFunction = CAValueFunction(name: kCAValueFunctionRotateZ)

等等

> rotation.x – > kCAValueFunctionRotateX> rotation.y – > kCAValueFunctionRotateY> rotation.z – > kCAValueFunctionRotateZ>旋转 – > kCAValueFunctionRotateZ> scale.x – > kCAValueFunctionScaleX> scale.y – > kCAValueFunctionScaleY> scale.z – > kCAValueFunctionScaleZ>规模 – > kCAValueFunctionScale> translation.x – > kCAValueFunctionTranslateX> translation.y – > kCAValueFunctionTranslateY> translation.z – > kCAValueFunctionTranslateZ>翻译 – > kCAValueFunctionTranslate

网友评论