您应该附上您的代码以将您的球移动到一个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] 删除。
我来说两句