iOS-UIImage 互转 UIColor

//UIColor 转UIImage
- (UIImage*) createImageWithColor: (UIColor*) color
{
    CGRect rect=CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);

    UIImage *senderImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return senderImage;
}

//UIImage转UIColor
[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];

你可能感兴趣的:(color,uiimage)