HXPhotoPickeriOS 圖片/視頻選擇器
HXPhotoPicker 是一個 IOS 圖片/視頻選擇器 - 支持 LivePhoto、GIF 圖片選擇、3DTouch 預(yù)覽、在線下載 iCloud 上的資源、編輯圖片/視頻、瀏覽網(wǎng)絡(luò)圖片等功能
特性 - Features
- 查看、選擇GIF圖片
- 照片、視頻可同時多選/原圖
- 3DTouch預(yù)覽照片
- 長按拖動改變順序
- 自定義相機拍照、錄制視頻
- 自定義轉(zhuǎn)場動畫
- 查看、選擇LivePhoto iOS9.1以上才有用
- 瀏覽網(wǎng)絡(luò)圖片、網(wǎng)絡(luò)視頻
- 仿微信編輯圖片功能
- 自定義裁剪視頻時長
- 傳入本地圖片、視頻
- 在線下載iCloud上的資源
- 兩種相冊展現(xiàn)方式(列表、彈窗)
- 支持Cell上添加
- 支持草稿功能
- 同一界面多個不同選擇器
- 支持暗黑模式
- 支持橫向布局
- 支持Xib和Masonry布局
- 支持自定義item的大小
- 支持滑動手勢選擇
要求 - Requirements
- iOS8及以上系統(tǒng)可使用. ARC環(huán)境. - iOS 8 or later. Requires ARC
- 訪問相冊和相機需要配置四個info.plist文件
- Privacy - Photo Library Usage Description 和 Privacy - Camera Usage Description 以及 Privacy - Microphone Usage Description
- Privacy - Location When In Use Usage Description 使用相機拍照時會獲取位置信息
- 相機拍照功能請使用真機調(diào)試
應(yīng)用示例 - Examples
跳轉(zhuǎn)相冊選擇照片
// 懶加載 照片管理類 - (HXPhotoManager *)manager { if (!_manager) { _manager = [[HXPhotoManager alloc] initWithType:HXPhotoManagerSelectedTypePhotoAndVideo]; } return _manager; } // 方法一: HXWeakSelf [self hx_presentSelectPhotoControllerWithManager:self.manager didDone:^(NSArray<HXPhotoModel *> *allList, NSArray<HXPhotoModel *> *photoList, NSArray<HXPhotoModel *> *videoList, BOOL isOriginal, UIViewController *viewController, HXPhotoManager *manager) { weakSelf.total.text = [NSString stringWithFormat:@"總數(shù)量:%ld ( 照片:%ld 視頻:%ld )",allList.count, photoList.count, videoList.count]; weakSelf.original.text = isOriginal ? @"YES" : @"NO"; NSSLog(@"block - all - %@",allList); NSSLog(@"block - photo - %@",photoList); NSSLog(@"block - video - %@",videoList); } cancel:^(UIViewController *viewController, HXPhotoManager *manager) { NSSLog(@"block - 取消了"); }]; // 方法二: // 照片選擇控制器 HXCustomNavigationController *nav = [[HXCustomNavigationController alloc] initWithManager:self.manager delegate:self]; [self presentViewController:nav animated:YES completion:nil]; // 通過 HXCustomNavigationControllerDelegate 代理返回選擇的圖片以及視頻 /** 點擊完成按鈕 @param photoNavigationViewController self @param allList 已選的所有列表(包含照片、視頻) @param photoList 已選的照片列表 @param videoList 已選的視頻列表 @param original 是否原圖 */ - (void)photoNavigationViewController:(HXCustomNavigationController *)photoNavigationViewController didDoneAllList:(NSArray<HXPhotoModel *> *)allList photos:(NSArray<HXPhotoModel *> *)photoList videos:(NSArray<HXPhotoModel *> *)videoList original:(BOOL)original; /** 點擊取消 @param photoNavigationViewController self */ - (void)photoNavigationViewControllerDidCancel:(HXCustomNavigationController *)photoNavigationViewController;
單獨選擇照片/適配編輯功能
// 單獨使用照片編輯功能 HXPhotoModel *photoModel = [HXPhotoModel photoModelWithImage:[UIImage imageNamed:@"1"]]; [self hx_presentPhotoEditViewControllerWithManager:self.manager photoModel:photoModel delegate:nil done:^(HXPhotoModel *beforeModel, HXPhotoModel *afterModel, HXPhotoEditViewController *viewController) { // beforeModel編輯之前、afterModel編輯之后 weakSelf.imageView.image = afterModel.thumbPhoto; } cancel:^(HXPhotoEditViewController *viewController) { // 取消 }]; // 單獨使用仿微信編輯功能 [self hx_presentWxPhotoEditViewControllerWithConfiguration:self.manager.configuration.photoEditConfigur photoModel:photoModel delegate:nil finish:^(HXPhotoEdit * _Nonnull photoEdit, HXPhotoModel * _Nonnull photoModel, HX_PhotoEditViewController * _Nonnull viewController) { if (photoEdit) { // 有編輯過 weakSelf.imageView.image = photoEdit.editPreviewImage; }else { // 為空則未進行編輯 weakSelf.imageView.image = photoModel.thumbPhoto; } // 記錄下當(dāng)前編輯的記錄,再次編輯可在上一次基礎(chǔ)上進行編輯 weakSelf.photoEdit = photoEdit; } cancel:^(HX_PhotoEditViewController * _Nonnull viewController) { // 取消 }]; // 單獨使用視頻編輯功能 NSURL *url = [[NSBundle mainBundle] URLForResource:@"QQ空間視頻_20180301091047" withExtension:@"mp4"]; HXPhotoModel *videoModel = [HXPhotoModel photoModelWithVideoURL:url]; [self hx_presentVideoEditViewControllerWithManager:self.manager videoModel:videoModel delegate:nil done:^(HXPhotoModel *beforeModel, HXPhotoModel *afterModel, HXVideoEditViewController *viewController) { // beforeModel編輯之前、afterModel編輯之后 weakSelf.imageView.image = afterModel.thumbPhoto; } cancel:^(HXVideoEditViewController *viewController) { // 取消 }];
評論
圖片
表情
