/**
- 根据颜色生成一张图片
- @param color 颜色
- @param size 图片大小
- @return 图片
*/
-
(UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
if (color) {
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;
}
return nil;
}