小编Mar*_*røt的帖子

Swift Progress View 动画使栏走得更远超过 100%

为 ProgressView 使用动画时,如果我让动画用完,它会完全正常,但是如果我在动画仍在运行时再次尝试运行此代码,它将向当前条添加 100% 并使其通过条. 图像应该更合乎逻辑地解释情况。

进度从 1.0 (100%) 开始:

在此处输入图片说明

进展已经进行了一半:

进展已经进行了一半

代码再次运行,导致进度超过 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)

提前致谢!

uiview ios animatewithduration swift

1
推荐指数
2
解决办法
6144
查看次数

标签 统计

animatewithduration ×1

ios ×1

swift ×1

uiview ×1