gpt4 book ai didi

ios - UIView animateKeyFrames 没有按预期工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:20:59 24 4
gpt4 key购买 nike

我正在尝试为飞机起飞场景制作动画。我在这里使用 UIView animatekeyFrames 方法并提供所需的关键帧,但最后一个关键帧没有动画,我附上了一个 GIF,您可以在其中看到最终翻译中的故障。

This is how it currently looks

这是我的整个动画代码,谁能帮我解决这里出了什么问题?

UIView.animateKeyframes(withDuration: 1.5, delay: 4.0, animations: {
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 1.0, animations: {
self.plane.center.x += 300
self.plane.center.y -= 60
})
UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.5, animations: {
self.plane.transform = CGAffineTransform(rotationAngle: -.pi/16)
})
UIView.addKeyframe(withRelativeStartTime: 1.01, relativeDuration: 0.49, animations: {
self.plane.center.x += 300
self.plane.center.y -= 60
})
}, completion: nil)

最佳答案

relativeStartTimerelativeDuration 必须在 01 的范围内。

参见 https://developer.apple.com/documentation/uikit/uiview/1622554-addkeyframe

关于ios - UIView animateKeyFrames 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51076481/

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