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?
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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With