Skip to content

Instantly share code, notes, and snippets.

@mikekatz
Created February 4, 2013 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikekatz/4708775 to your computer and use it in GitHub Desktop.
Save mikekatz/4708775 to your computer and use it in GitHub Desktop.
Create a simple colored square image. From my UI utils repo https://github.com/mikekatz/iOS-UI-Utils
+ (UIImage*) imageWithColor:(UIColor*)color size:(CGSize)size
{
UIGraphicsBeginImageContext(size);
UIBezierPath* rPath = [UIBezierPath bezierPathWithRect:CGRectMake(0., 0., size.width, size.height)];
[color setFill];
[rPath fill];
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment