Skip to content

Instantly share code, notes, and snippets.

@tediscript
Created April 3, 2013 05:04
Show Gist options
  • Select an option

  • Save tediscript/5298571 to your computer and use it in GitHub Desktop.

Select an option

Save tediscript/5298571 to your computer and use it in GitHub Desktop.
- (UIImage*) drawText:(NSString*)text inImage:(UIImage*)bgImage atPoint:(CGPoint)point withSize:(CGFloat)size withColor:(UIColor*) color {
UIGraphicsBeginImageContextWithOptions(bgImage.size, FALSE, 0.0);
[bgImage drawInRect:CGRectMake( 0, 0, bgImage.size.width, bgImage.size.height)];
UIFont *font = [UIFont boldSystemFontOfSize:size];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(ctx, color.CGColor);
[text drawAtPoint:point withFont:font];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment