首页 > 其他 > 详细

第43月第10天 uiimage写文件

时间:2020-04-10 10:27:07      阅读:78      评论:0      收藏:0      [点我收藏+]

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写文件

原文:https://www.cnblogs.com/javastart/p/12671634.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!