IOS 一个将颜色转化为UIImage的函数

- (UIImage *)imageWithColor:(UIColor *)color {

CGRect rect = CGRectMake(0, 0, 1, 1);

UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);

[color setFill];

UIRectFill(rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;

}

你可能感兴趣的:(IOS 一个将颜色转化为UIImage的函数)