标签:style blog io color os 使用 sp div on
#import <UIKit/UIKit.h> @interface UIImage (ImageWithColor) + (UIImage *)imageWithColor:(UIColor *)color; @end #import "UIImage+ImageWithColor.h" @implementation UIImage (ImageWithColor) + (UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0, 0, 1, 1); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } @end // 使用
UIColor *purpleColor = [UIColor colorWithRed:.927f green:.264f blue:.03f alpha:1];
UIImage *image = [UIImage imageWithColor:purpleColor];
标签:style blog io color os 使用 sp div on
原文地址:http://www.cnblogs.com/joesen/p/4074174.html