- 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 *theImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return theImage;
- }
- UIImage转UIColor
- [UIColor colorWithPatternImage:[UIImageimageNamed:@“bg.png"]]
iOS中uiimage和uicolor相互转化
最新推荐文章于 2020-12-10 20:05:53 发布