1

So I have a UIProgressview in storyboard and I set the height constraint via storyboard and it's the height I expect and everything with that is sunshine and rainbows.

My problem comes into play when I'm setting the progress of it, I call cell.progressBar.setProgress(22, animated: true) (I'm using tableview cells btw for multiple progress bars) and it fills the bar as expected BUT it also animates the height constraint so it goes from a height of 9 to a height of 25 or whatever I set. I don't want this behavior.

Also it's worth mentioning that when I have other cells with progress bars in them and I only need to set 1, the other progress bars don't animate their height constraint, they simply have an empty bar with correct height (what I expect).

And I want to note that I'm setting the progress for every cell (variable number of cells) in cellForRowAtIndexPathso I'm not sure why setting the progress animates the height constraint and not setting the progress has the height constraint already fixed like I want. I do want the fill animation just without the height constraint being animated also.

Any help would be greatly appreciated.

Code for cell for row if it helps

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCell(withIdentifier: "basic_result_cell", for: indexPath) as! BasicResultCell

    UIView.animate(withDuration: 1.0, animations: {

        cell.progressBar.setProgress((Int(25))%, animated: true)
    })

    return cell

}
Andrew Edwards
  • 1,005
  • 1
  • 9
  • 24

1 Answers1

1

Thanks to Badhan for pointing it might be a thread issue. here's what I did to fix it. Probably due to it being a closure or something. Anywho this works.

   UIView.animate(withDuration: 1.0, animations: {

       DispatchQueue.main.async {
           cell.progressBar.setProgress((Int(25))%, animated: true)
       }
   })
Andrew Edwards
  • 1,005
  • 1
  • 9
  • 24