问题描述
let flyRight = CABasicAnimation(keyPath: "position.x")
flyRight.toValue = view.bounds.size.width/2
flyRight.duration = 0.5
flyRight.fromValue = -view.bounds.size.width/2
flyRight.fillMode = kCAFillModeBoth
flyRight.beginTime = CACurrentMediaTime() + 3.4
password.layer.position.x = view.bounds.size.width/2
password.layer.addAnimation(flyRight, forKey: nil)
我的问题是:在添加动画之前,怎么可能先将图层放置在结束位置,但是当应用程序启动时,在动画之前我看不到它开始吗?取而代之的是,动画会在3.4秒后按预期方式工作。
My question is: how is it possible that before I am adding the animation, I first put the layer at the end position, but when the app goes up, I don't see it there before the animation starts? Instead, the animation works after 3.4 seconds as expected.
我的意思是,iOS如何知道首先需要运行动画,然后再将图层放置到最终位置?
I mean, how iOS knows that first it needs to run the animation and only then put the layer to it's final position?
推荐答案
这是因为存在 presentationLayer
和 modelLayer
以便动画显示并修改 presentationLayer
,所以 presentationLayer
就像是鬼
This is because there is a presentationLayer
and a modelLayer
so animation show and modify presentationLayer
, so presentationLayer
is like a ghost.
您可以在这里找到更多信息
you can find more info here https://www.objc.io/issues/12-animations/animations-explained/
我希望这对您有帮助
这篇关于iOS层动画-说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!