Reputation: 11
I am trying to update progress bar based on the server data. So, if value received (in %) is less than 90 then the progress bar should be green else it should be red in colour.
if (value >= 90) {
progressBar.progressTintColor = UIColor.redColor()
} else
{
progressBar.progressTintColor = UIColor.greenColor()
}
progressBar.setProgress(Float(value)/100, animated : true)
The above code works fine except for range 0.01 - 0.05. Any value between this range always shows progress as 0.05 only. If I comment out the code to update color then it seems to be working fine.
I am updating everything on main thread. Also, I observed that calling this method from viewDidLoad and viewWillAppear does not impact the progress.
Similar question is posted in below link - UIProgressView doesn't update <=0.5 value after Changing ProgressTintColor
but, it is not yet answered.
Any help to solve this issue will be appreciated.
Upvotes: 1
Views: 670
Reputation: 636
Try this
DispatchQueue.main.async {
if (value >= 90) {
progressBar.progressTintColor = UIColor.redColor()
} else
{
progressBar.progressTintColor = UIColor.greenColor()
}
progressBar.setProgress(value, animated : true)
}
Upvotes: 0