How to write animated GIF to iOS camera roll?

2020-02-13 06:15发布

How do you write an animated GIF to the iOS camera roll? I understand that the photo gallery app is not able to play animations, but for example I should be able to import it when sending an email, etc.

I've tried:

UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:self.imageData], nil, nil, nil);

But this seems to convert it to a jpg.

标签: iphone ios ios6
2条回答
beautiful°
2楼-- · 2020-02-13 07:09

You can use gif in iOS email attachment like this.

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:@""];

// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"Your image name" ofType:@"gif"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/gif" fileName:@"photo name"];

NSString *emailBody = @"";
[picker setMessageBody:emailBody isHTML:NO];

[self presentModalViewController:picker animated:YES];
[picker release];
查看更多
孤傲高冷的网名
3楼-- · 2020-02-13 07:11

Create an ALAssetLibrary instance. Use this method with your NSData: writeImageDataToSavedPhotosAlbum:metadata:completionBlock:

Reference

查看更多
登录 后发表回答