Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIProgressView not animating progress on iOS 13

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?

like image 597
Samy Avatar asked Sep 16 '19 23:09

Samy


Video Answer


2 Answers

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)
like image 148
Farshad jahanmanesh Avatar answered Oct 07 '22 16:10

Farshad jahanmanesh


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)
like image 25
atulkhatri Avatar answered Oct 07 '22 14:10

atulkhatri