【问题标题】:UIProgressView not animating progress on iOS 13UIProgressView 在 iOS 13 上没有动画进度
【发布时间】:2019-09-16 23:02:48
【问题描述】:

我没有看到带有 Xcode 11.0/Swift 5/iOS 13 的 UIProgressView 的动画:

private let timerProgressView: UIProgressView = {
    let timerProgressView = UIProgressView()
    timerProgressView.progressTintColor = white
    timerProgressView.trackTintColor = .black
    timerProgressView.setProgress(1.0, animated: false)
    return timerProgressView
}()

private func triggerProgressView() {
    UIView.animate(withDuration: viewModel.timeLimit, delay: 0.0, options: .curveLinear, animations: { [weak self] in
        self?.timerProgressView.setProgress(0.0, animated: true)
    }, completion: nil)
}

此代码适用于 iOS

【问题讨论】:

  • 同样的问题,请分享任何解决方案:(
  • 谢谢,但这太荒谬了,我放弃了 ProgressView 以寻求一个明智的选择,请随意看看 github.com/ueen/SensibleProgressView :)

标签: swift xcode uiprogressview ios13


【解决方案1】:

我们也遇到过这个问题,经过大约一个小时的拉头发后,我们想出了一个解决方法,看起来这是一个错误。这很荒谬,但是将进度设置为 0.0001 而不是 0.0 就可以了

progressView.progress = 0.0001
UIView.animate(withDuration: duration,
                   delay: 0.0, options: [.curveLinear, .beginFromCurrentState, .preferredFramesPerSecond60],
                   animations: { progressView.layoutIfNeeded() },
                   completion: nil)

【讨论】:

    【解决方案2】:

    您是否尝试过这样做? :

    self?.timerProgressView.setProgress(0.0) 
    UIView.animate(withDuration: viewModel.timeLimit, delay: 0.0, options: .curveLinear, animations: { [weak self] in
        self?.timerProgressView.layoutIfNeeded() 
    }, completion: nil)
    

    【讨论】:

      猜你喜欢
      • 2020-05-30
      • 2014-02-27
      • 1970-01-01
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多