Skip to content

Instantly share code, notes, and snippets.

@TheCodeEngine
Last active October 11, 2015 00:08
Show Gist options
  • Save TheCodeEngine/3772096 to your computer and use it in GitHub Desktop.
Save TheCodeEngine/3772096 to your computer and use it in GitHub Desktop.
Build wit CoreGraphics UIImage
- (UIImage*) buildSwatch: (int) aBrightness
{
CGRect rect = CGRectMake(0.0f, 0.0f, 30.0f, 30.0f);
UIGraphicsBeginImageContext(rect.size);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:4.0f];
[[[UIColor blackColor] colorWithAlphaComponent:(float) aBrightness / 10.0f] set];
[path 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