ios - UIView animateKeyFrames 未按预期工作
<p><p>我正在尝试制作飞机起飞场景的动画。这里我使用 UIView animatekeyFrames 方法并提供所需的关键帧,但最后一个关键帧没有动画,我附上了一个 GIF,您可以在其中看到最终翻译中的故障。</p>
<p> <a href="/image/ZFDeo.gif" rel="noreferrer noopener nofollow"><img src="/image/ZFDeo.gif" alt="This is how it currently looks"/></a> </p>
<p>这是我的整个动画代码,谁能帮我解决这里出了什么问题?</p>
<pre><code>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)
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><code>relativeStartTime</code> 和 <code>relativeDuration</code> 必须在 <strong>0</strong> 和 <strong>1</strong> 的范围内。 </p>
<p>见 <a href="https://developer.apple.com/documentation/uikit/uiview/1622554-addkeyframe" rel="noreferrer noopener nofollow">https://developer.apple.com/documentation/uikit/uiview/1622554-addkeyframe</a> </p></p>
<p style="font-size: 20px;">关于ios - UIView animateKeyFrames 未按预期工作,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/51076481/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/51076481/
</a>
</p>
页:
[1]