第43月第10天 uiimage写文件
Posted javastart
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第43月第10天 uiimage写文件相关的知识,希望对你有一定的参考价值。
1.
-(void)saveImage:(CGImageRef)image directoryURL:(NSURL*)directoryURL filename:(NSString*)filename { @autoreleasepool { NSURL *fileURL = [directoryURL URLByAppendingPathComponent:filename]; // fileURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", directory, filename]]; CFURLRef url = (__bridge CFURLRef)fileURL; CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL); CGImageDestinationAddImage(destination, image, nil); if (!CGImageDestinationFinalize(destination)) NSLog(@"ERROR saving: %@", url); CFRelease(destination); // CGImageRelease(image); NSLog(@"saveImage: %@", fileURL); } }
+ (UIImage *)imageWithColor:(UIColor *)color AndRect:(CGRect)rect{ UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }
https://www.cnblogs.com/piaojin/p/5066090.html
https://www.jianshu.com/p/942f974f5c30
以上是关于第43月第10天 uiimage写文件的主要内容,如果未能解决你的问题,请参考以下文章