7

I am not seeing the animation of a UIProgressView with Xcode 11.0/Swift 5/iOS 13:

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)
}

This code works on iOS <12 but not on iOS 13. Am I missing something?

Samy
  • 1,172
  • 9
  • 13
  • same issue, please share any solution :( – ueen Sep 21 '19 at 09:25
  • Thanks, but this is ridiculous, I abandoned the ProgressView for a sensible alternative, feel free to take a look https://github.com/ueen/SensibleProgressView :) – ueen Sep 23 '19 at 20:54

2 Answers2

5

we've faced it too and after about an hour of hair pulling we came up with a workaround, it looks like that is a bug. it ridiculous, but setting the progress to 0.0001 instead of 0.0 will do the job.

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

Did you try doing something like this? :

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