2017-06-18 62 views
0
//MARK: - TableView Delegate 
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCell(
     withIdentifier: "ListOfTaskTableViewCell", 
     for: indexPath) as! ListOfTaskTableViewCell 

    //Configuare notification cell 
    print(self.listItems.count) 
    cell.lblName?.text = self.listItems[indexPath.row] 
    cell.lblPersentage?.text = self.listPersentage [indexPath.row] 
    cell.imgPersentageIcon?.image = UIImage(named: self.listIcons[indexPath.row]) 
    //Set as comment 

    if self.floatPercentage[indexPath.row] >= 50.0 { 
     cell.redProgressBar.isHidden = true 
     UIView.animate(withDuration: 10.0, animations: { 
      cell.greenProgressBar.value = CGFloat(self.floatPercentage[indexPath.row]) 
      }, completion: nil) 

    } 
    else{ 
     cell.greenProgressBar.isHidden = true 

     UIView.animate(withDuration: 10.0, animations: { 
      cell.redProgressBar.value = CGFloat(self.floatPercentage[indexPath.row]) 
      }, completion: nil) 

    }     

    return cell 
} 

imageMBCircularProgressBarView不UITableViewCell的動畫

回答

0

嘗試這WillDisplayCell

if self.floatPercentage[indexPath.row] >= 50.0 { 
    cell.redProgressBar.isHidden = true 
    UIView.animate(withDuration: 10.0, animations: { 
     cell.greenProgressBar.value = CGFloat(self.floatPercentage[indexPath.row]) 
     }, completion: nil) 

} 
else{ 
    cell.greenProgressBar.isHidden = true 

    UIView.animate(withDuration: 10.0, animations: { 
     cell.redProgressBar.value = CGFloat(self.floatPercentage[indexPath.row]) 
     }, completion: nil) 

}