为 ProgressView 使用动画时,如果我让动画用完,它会完全正常,但是如果我在动画仍在运行时再次尝试运行此代码,它将向当前条添加 100% 并使其通过条. 图像应该更合乎逻辑地解释情况。
进度从 1.0 (100%) 开始:
进展已经进行了一半:
代码再次运行,导致进度超过 100%,尽管它使用了正确的时间来完成。
这是使用的代码:
self.progressView.setProgress(1.0, animated: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
UIView.animate(withDuration: 10, delay: 0, options: [.beginFromCurrentState, .allowUserInteraction], animations: { [unowned self] in
self.progressView.setProgress(0, animated: true)
})
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!