Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
Created April 6, 2015 03:31
Show Gist options
  • Save wisaruthk/0ffb6bf86bb941a4e2ef to your computer and use it in GitHub Desktop.
Save wisaruthk/0ffb6bf86bb941a4e2ef to your computer and use it in GitHub Desktop.
Cell with customize cell image
CGRect mybounds = CGRectMake(0, 0, 20, 20);
UIGraphicsBeginImageContext( mybounds.size );
CGContextRef context = UIGraphicsGetCurrentContext();
CIColor *itemColor = [CIColor colorWithString:item.color];
CGContextSetFillColorWithColor(context, [[UIColor colorWithCIColor:itemColor] CGColor]);
CGContextFillRect(context, mybounds);
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
cell.imageView.image = finalImage;
cell.imageView.layer.cornerRadius = mybounds.size.height/2.0f;
cell.imageView.clipsToBounds = YES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment