- @interface UIImage (Color)
-
- + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;
-
- @end
-
- @implementation UIImage (Color)
-
- + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
- {
- CGRect rect = CGRectMake(0, 0, size.width, size.height);
- UIGraphicsBeginImageContext(rect.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextSetFillColorWithColor(context,color.CGColor);
- CGContextFillRect(context, rect);
- UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- return img;
- }
- @end
用色值生成图片
原文:http://www.cnblogs.com/huangzhenwei/p/5958006.html