简单试试Live Photo怎么用

2016-11-20  本文已影响65人  Johnny_Chang

http://nicreals.github.io/2016/03/09/Live-Photo/#more(此人博客不错)

另外jianshu关注了部分文章,也不错

自己的代码

- (IBAction)choosePhotos:(id)sender {

UIImagePickerController*picker = [[UIImagePickerControlleralloc]init];

picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

picker.allowsEditing=NO;

picker.delegate=self;

NSArray*mediaTypes =@[(NSString*)kUTTypeImage,(NSString*)kUTTypeLivePhoto];

picker.mediaTypes= mediaTypes;

[selfpresentViewController:pickeranimated:YEScompletion:nil];

}

- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

[selfdismissViewControllerAnimated:YEScompletion:^{

PHLivePhoto*photo = [infoobjectForKey:UIImagePickerControllerLivePhoto];

if(photo)

{

PHLivePhotoView*photoView = [[PHLivePhotoViewalloc]initWithFrame:self.view.bounds];

photoView.livePhoto= [infoobjectForKey:UIImagePickerControllerLivePhoto];

photoView.contentMode=UIViewContentModeScaleAspectFill;

[self.viewaddSubview:photoView];

}else

{

//self.LivePhotos.image =

NSLog(@"普通相片");

}

}];

}

注意:

1.plist :Privacy - Photo Library Usage Description

2.#import 《photo。h》

3.

上一篇下一篇

猜你喜欢

热点阅读