UIImage和UIColor的转换

来源:互联网 发布:淘宝网运动器材 编辑:程序博客网 时间:2024/06/07 00:26
//UIColor 转UIImage- (UIImage*) createImageWithColor: (UIColor*) color{    CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);    UIGraphicsBeginImageContext(rect.size);    CGContextRef context = UIGraphicsGetCurrentContext();    CGContextSetFillColorWithColor(context, [color CGColor]);    CGContextFillRect(context, rect);    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();    return theImage;}//UIImage转UIColor[UIColor colorWithPatternImage:[UIImageimageNamed:@"bg.png"]]

0 0
原创粉丝点击