标签:
//UIColor 转UIImage
- (UIImage*)imageWithColor: (UIColor*)color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 100.0f, 50.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *Image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return Image;
}
//UIImage转UIColor
UIButton *Button = [[UIButton alloc] initWithFrame:CGRectMake(20, 200, 100,50)];
UIImage *image = [UIImage imageNamed:@"radio_bn.png"];
[cancelButton setBackgroundColor:[UIColor colorWithPatternImage:image]];
标签:
原文地址:http://www.cnblogs.com/Sucri/p/5091106.html