CircularProgressBar color chagnes while scrolling collectionview

时间:2018-12-03 13:19:44

标签: ios objective-c collectionview

I have tried grand dispatch code and prepareForReuse function as well. but issue could not be solved.

- ( UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    //    @synchronized(self) {
    static NSString *cellIdentifier = @"Goalprogress_Cell";
    GoalprogressCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

    Goal_Class *CellClass = [MyGoalArray objectAtIndex:indexPath.row];

    if ([CellClass.Status  isEqual: @"Completed"])
    {
        NSString *color = @"black";
        NSLog(@"Color == %@ Goal name == %@ Goal Status == %@",color,CellClass.GoalName,CellClass.Status);

        cell.Upperprogress.progressColor = [UIColor colorWithRed:0.0f/255.0f
                                                               green:180.0f/255.0f
                                                                blue:0.0f/255.0f
                                                               alpha:1.0f];
        cell.Upperprogress.progressStrokeColor = [UIColor colorWithRed:0.0f/255.0f
                                                                     green:180.0f/255.0f
                                                                      blue:0.0f/255.0f
                                                                     alpha:1.0f];
        cell.LowerprogressView.progressColor = [UIColor colorWithRed:0.0f/255.0f
                                                           green:180.0f/255.0f
                                                            blue:0.0f/255.0f
                                                           alpha:1.0f];
        cell.LowerprogressView.progressStrokeColor = [UIColor colorWithRed:0.0f/255.0f
                                                                 green:180.0f/255.0f
                                                                  blue:0.0f/255.0f
                                                                 alpha:1.0f];

        cell.LowerprogressView.hidden = false;
        cell.Upperprogress.hidden = false;
    } else {
        NSString *color = @"blue";
        NSLog(@"Color == %@ Goal name == %@ Goal Status == %@",color,CellClass.GoalName,CellClass.Status);
//        cell.Upperprogress.hidden = false;
//        cell.LowerprogressView.hidden = false;

                cell.Upperprogress.progressColor = [UIColor colorWithRed:255.0f/255.0f
                                                               green:252.0f/255.0f
                                                                blue:121.0f/255.0f
                                                               alpha:1.0f];
        cell.Upperprogress.progressStrokeColor = [UIColor colorWithRed:255.0f/255.0f
                                                                     green:252.0f/255.0f
                                                                      blue:121.0f/255.0f
                                                                     alpha:1.0f];
        cell.LowerprogressView.progressColor = [UIColor colorWithRed:0.0f/255.0f
                                                           green:180.0f/255.0f
                                                            blue:0.0f/255.0f
                                                           alpha:1.0f];
        cell.LowerprogressView.progressStrokeColor = [UIColor colorWithRed:0.0f/255.0f
                                                                 green:180.0f/255.0f
                                                                  blue:0.0f/255.0f
                                                                 alpha:1.0f];

        cell.LowerprogressView.hidden = false;
        cell.Upperprogress.hidden = false;

//        NSLog(@"after dispatch async");
    }

0 个答案:

没有答案