我没有在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

最佳答案

我们也已经遇到了问题,经过大约一个小时的梳理,我们想出了一种解决方法,看来这是一个错误。这很荒谬,但是将进度设置为0.0001而不是0.0会完成的工作。

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

关于swift - UIProgressView不能在iOS 13上显示动画进度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57965347/

10-12 05:46