Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create UIImage rectangle from color
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0, 0, 1, 1);
// Create a 1 by 1 pixel context
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[color setFill];
UIRectFill(rect); // Fill it with your color
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
return image;
// source:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment