您如何将动画 GIF 写入 iOS 相机胶卷?我了解照片库应用程序无法播放动画,但例如我应该能够在发送电子邮件等时导入它。
我试过了:
UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:self.imageData], nil, nil, nil);
但这似乎将其转换为jpg。
创建一个ALAssetLibrary
实例。将此方法与您的NSData
:writeImageDataToSavedPhotosAlbum:metadata:completionBlock:
您可以像这样在 iOS 电子邮件附件中使用 gif。
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];