Skip to content

Instantly share code, notes, and snippets.

View uknowho's full-sized avatar

Lonny Gomes uknowho

View GitHub Profile
@uknowho
uknowho / UIImage+withColor.m
Created July 3, 2013 04:02
A quick way to create an UIImage of a solid color for a specified dimension. You can use this bit of code in an Objective-C category to "extend" UIImage.
+ (UIImage *)imageWithColor:(UIColor *)color andBounds:(CGRect)imgBounds {
UIGraphicsBeginImageContextWithOptions(imgBounds.size, NO, 0);
[color setFill];
UIRectFill(imgBounds);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}