bookmark

Things that were not immediately obvious to me » Blog Archive » Shiny Red Buttons (Digression)


Description

// Text bounds NSString* text = @"Big Button"; UIFont* font = [UIFont boldSystemFontOfSize:18]; CGSize size = [text sizeWithFont:font]; // Rendering context UIGraphicsBeginImageContext(size); CGContextRef context = UIGraphicsGetCurrentContext(); // Set colors CGContextSetFillColorWithColor(context, [[UIColor greenColor] CGColor]); CGContextSetStrokeColorWithColor(context, [[UIColor greenColor] CGColor]); // Render [text drawInRect:CGRectMake(0, 0, size.width, size.height) withFont:font]; // Create image and release context UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

Preview

Tags

Users

  • @slbaron

Comments and Reviews