2
我目前需要一个图层(CALayer),我可以在这些比例之间缩放来创建动画。如何减慢CALayer.transform动画?
private let invisibleScale = CATransform3DMakeScale(0.0,0.0,1.0)
private let fullScale = CATransform3DMakeScale(2.5,2.5,1.0)
通过简单地调用我的层下面的功能层动画就像我希望它(除了有点快)。
animationLayer.transform = invisibleScale
animationLayer.transform = fullScale
我试图与转化为价值,但因为它会回到原来的规模完成了动画之后不起作用加CABasicAnimation。事情是这样的:
let animation = CABasicAnimation(keyPath: "transform")
animation.toValue = NSValue(caTransform3D: invisibleScale)
animation.duration = animationDuration
animationLayer.add(animation, forKey: "transform")
所以,我想加入animationLayer.transform =满量程末动画后更新的状态。
let animation = CABasicAnimation(keyPath: "transform")
animation.toValue = NSValue(caTransform3D: invisibleScale)
animation.duration = animationDuration
animationLayer.add(animation, forKey: "transform")
animationLayer.transform = fullScale
这导致看起来完全一样,只是打电话动画:
animationLayer.transform = fullScale
我也尝试这样的东西:
UIView.animate(withDuration: 10) {
self.animationLayer.transform = fullScale
}
这也以相同的速度动画只需键入animationLayer.transform = invisibleScale。
如何使这项工作的任何提示将不胜感激!