将color转为UIImage

来源:互联网 发布:淘宝达人后台网址 编辑:程序博客网 时间:2024/05/16 16:55
//将color转为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;}
0 0
原创粉丝点击