+(UIImage*)imageFromColor:(UIColor*)color size:(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;
}
网友评论