【发布时间】:2024-04-14 18:00:01
【问题描述】:
我正在使用 UIView 动画功能测试一些东西,我对您对动画缺乏控制感到有些困惑。也许我错过了什么
UIView.animate(
withDuration: TimeInterval(Int.random(in: 20 ..< 25)),
delay: TimeInterval(cloudConfig.delay),
options: [
UIView.AnimationOptions.curveLinear,
UIView.AnimationOptions.repeat,
],
animations: {
self.view.transform = CGAffineTransform(translationX: width, y: 0)
self.parent!.layoutIfNeeded() // important for the animation
},
completion: { _ in
print("hurray I know when it ends, if it would fire on repeat as well :) it does not")
}
)
此动画只是将视图从左向右移动并重复该过程。我似乎无法在 api 中找到任何可以让我寻找动画的特定时间并从那里开始的东西。或者简单的事情,比如暂停和播放,或者获取当前的播放位置。有没有办法对动画进行一些控制,它几乎就像 css 动画 - 零控制。
感谢任何提示
【问题讨论】:
标签: swift animation uiview uiviewanimation