IT虾米网

UIColor转换为UIImage

developer 2018年06月23日 手机开发 1026 0
/** 
 *  color转image 
 */ 
- (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; 
}

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

iOS 图片压缩 和等比压缩 指定缩放比例压缩