//UIColor 轉UIImageit
- (UIImage*)imageWithColor: (UIColor*)colorio
{ im
CGRect rect=CGRectMake(0.0f, 0.0f, 100.0f, 50.0f);di
UIGraphicsBeginImageContext(rect.size);co
CGContextRef context = UIGraphicsGetCurrentContext();radio
CGContextSetFillColorWithColor(context, [color CGColor]);return
CGContextFillRect(context, rect);context
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]];