JDGImagePicker
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
要求
iOS : 11.0以上,仅支持iPhone
安装
JDGImagePicker 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
# 使用全部完整功能
pod 'JDGImagePicker'
# 仅使用图片选择器的功能
pod 'JDGImagePicker/ImagePicker'
# 仅使用预览的功能(开发中)
pod 'JDGImagePicker/ImagePreviewer'
用法
首先在 InfoPlist 中添加权限描述
NSCameraUsageDescription -> 隐私 - 相册使用描述 NSPhotoLibraryUsageDescription -> 隐私 - 摄像头使用描述
然后按照以下逻辑使用代码
//...
#import <JDGImagePicker/JDGImagePicker.h>
//...
@interface XXXViewController() <JDGImagePickerDelegate>
//...
@implementation XXXViewController
//...
- (void)actionToShowPicker {
//...
JDGImagePicker *picker = JDGImagePicker.shared;
picker.delegate = self;
JDGImagePickerConfiguration *config = JDGImagePickerConfiguration.shared;
config.imageSize = UIScreen.mainScreen.bounds.size;// or any other sizes
config.doneButtonTitle = @"完成";
config.cancelButtonTitle = @"取消";
[picker presentFromViewController:self animated:YES completion:^{
// complete animation
}];
}
#pragma mark - JDGImagePickerDelegate
- (void)imagePicker:(JDGImagePicker *)imagePicker didFinishWithResultSelection:(JDGImageStack *)resultSelection {
JDGImagePickerPhoto *photo = resultSelection.selectedPhotos.firstObject;
[photo getOriginImageInMainQueueCompletion:^(UIImage * _Nullable image, NSError * _Nullable error) {
// origin image here
}];
[photo getThumbnailImageInMainQueueCompletion:^(UIImage * _Nullable image, NSError * _Nullable error) {
// thumbnail image here, this run much faster
}];
// destroy Shared instance if you need
[JDGImagePicker destroyShared];
[JDGImagePickerConfiguration destroyShared];
}
- (void)imagePickerDidCancel:(JDGImagePicker *)imagePicker {
// destroy Shared instance if you need
[JDGImagePicker destroyShared];
[JDGImagePickerConfiguration destroyShared];
}
@end
作者
JDGan, [email protected]
许可协议
JDGImagePicker 可在 MIT 许可协议下使用。有关更多信息,请参阅 LICENSE 文件。