UIColor -> UIImage
/**
* 根据颜色和大小获取Image
*
* @param color 颜色
* @param size 大小
*
*/
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
UIGraphicsBeginImageContextWithOptions(size, 0, [UIScreen mainScreen].scale);
[color set];
UIRectFill(CGRectMake(0, 0, size.width, size.height));
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
UIImage -> UIColor
UIColor *color = [UIColor colorWithPatternImage:[UIImageimageNamed:@"Background"]]