+ (UIImage *)createImageWithColor:(UIColor *)color andSize:(CGSize)size { CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height); UIGraphicsBeginImageContext(size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return theImage; }
原文地址:http://blog.csdn.net/hherima/article/details/44218529