UIImage *(^createImageFromUIColor)(UIColor *) = ^(UIColor *color) { CGRect rect = CGRectMake(0, 0, 1, 1); UIGraphicsBeginImageContext(rect.size); CGContextRef contextRef = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(contextRef, [color CGColor]); CGContextFillRect(contextRef, rect); UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img