我尝试用JPG文件和MOV文件制作实时照片.就像这样:
CGSize targetSize = CGSizeZero;
PHImageContentMode contentMode = PHImageContentModeDefault;
__weak NSURL *videoUrl;
__weak NSURL *photoUrl;
// Call private API to create the live photo
self.livePhotoView.livePhoto = nil;
self.livePhoto = nil;
self.livePhoto = [[PHLivePhoto alloc] init];
SEL initWithImageURLvideoURL = NSSelectorFromString(@"_initWithImageURL:videoURL:targetSize:contentMode:");
if ([self.livePhoto respondsToSelector:initWithImageURLvideoURL]) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self.livePhoto methodSignatureForSelector:initWithImageURLvideoURL]];
[invocation setSelector:initWithImageURLvideoURL];
[invocation setTarget:self.livePhoto];
[invocation setArgument:&(photoURL) atIndex:2];
[invocation setArgument:&(videoUrl) atIndex:3];
[invocation setArgument:&(targetSize) atIndex:4];
[invocation setArgument:&(contentMode) atIndex:5];
[invocation invoke];
}
// Set the live photo
self.livePhotoView.livePhoto = self.livePhoto;
Run Code Online (Sandbox Code Playgroud)
最后,我得到了实时照片并在livePhotoView中显示它.然后我尝试保存或分享它.我使用Class UIActivityViewController.Like this:
if …Run Code Online (Sandbox Code Playgroud)