How do I save a UIImage to a file?

前端 未结 9 901
抹茶落季
抹茶落季 2020-12-07 13:13

If I have a UIImage from an imagePicker, how can I save it to a subfolder in the documents directory?

9条回答
  •  心在旅途
    2020-12-07 13:35

    NSData *imageData = UIImagePNGRepresentation(image);
    [imageData writeToFile:path atomically:YES];
    

    where path is the name of the file you want to write it to.

提交回复
热议问题