我的 UIImageView 在到达结束之前不会在屏幕上设置动画

诺布索南

单击播放按钮时,我试图将球从屏幕的一端带到另一端。在球到达屏幕右侧之前,我的代码不会重绘球。

罗刹夏斯特里

您应该附上您的代码以将您的球移动到一个UIView.animate块内。

UIView.animate(with: 1, animations: {
    //Code which animates your view
})

如果您想让代码在 1 秒动画后运行,请不要使用睡眠。在里面使用完成块UIView.animate

UIView.animate(with: 1, animations: {
    ball.center.x += balllVelocity
}, completion: (finished) in
    if finished {
        ball.center.x > view.frame.size.width {
            gameRunning = false
        }
    }
}

你可以做很多事情UIView.animate,我建议你阅读文档来改进你的动画。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章