Latest3.4
Homepagehttps://github.com/CheeryLau/MMImagePicker
LicenseMIT
Platformsios 7.0, requires ARC
FrameworksFoundation, UIKit, AssetsLibrary
Authors

MMImagePickerCheeryLau

License MIT 
CocoaPods 
CocoaPods 

MMImagePicker

MMImagePicker基于AssetsLibrary框架的图片选择器:支持多选、单选、对图片进行裁剪、选择原图、可预览。若想使用基于Photos框架的图片选择器,可选择MMPhotoPicker

属性

MMImagePickerController属性介绍:

// 主色调[默认蓝色]
@property (nonatomic, strong) UIColor *mainColor;
// 是否回传原图[可用于控制图片压系数]
@property (nonatomic, assign) BOOL isOrigin;
// 是否显示原图选项[默认NO]
@property (nonatomic, assign) BOOL showOriginImageOption;
// 是否只选取一张[默认NO]
@property (nonatomic, assign) BOOL singleImageOption;
// 是否选取一张且需要裁剪[默认NO]
@property (nonatomic, assign) BOOL cropImageOption;
// 裁剪的大小[默认方形、屏幕宽度]
@property (nonatomic, assign) CGSize imageCropSize;
// 最大选择数目[默认9张]
@property (nonatomic, assign) NSInteger maximumNumberOfImage;
// 代理
@property (nonatomic, assign) id<MMImagePickerDelegate> delegate;

代理

@protocol MMImagePickerDelegate <NSObject>

@optional
/**
 info释义:
 返回的媒体数据是数组,数组单元为字典,字典中包含以下数据:

 资源类型 ALAssetPropertyType
 位置方向 ALAssetPropertyLocation
 原始图片 UIImagePickerControllerOriginalImage
 原件路径 UIImagePickerControllerReferenceURL

 */- (void)mmImagePickerController:(MMImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray<NSDictionary *> *)info;
- (void)mmImagePickerControllerDidCancel:(MMImagePickerController *)picker;

@end

使用

  1. pod "MMImagePicker" ;
  2. pod install / pod update;
  3. #import <MMImagePicker/MMImagePickerController.h>.
MMImagePickerController *mmVC = [[MMImagePickerController alloc] init];
// 代理
mmVC.delegate = self;  
// 最大图片选择数量 
mmVC.maximumNumberOfImage = 9; 
// 显示原图选项
mmVC.showOriginImageOption = YES;
UINavigationController *mmNav = [[UINavigationController alloc] initWithRootViewController:mmVC];
[self.navigationController presentViewController:mmNav animated:YES completion:nil];
#pragma mark - MMImagePickerDelegate
- (void)mmImagePickerController:(MMImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
{
     NSLog(@"%@",info);
}

 - (void)mmImagePickerControllerDidCancel:(MMImagePickerController *)picker
{
     NSLog(@"Cancel");
}

注意

  1. 需要在Info.plist中添加隐私授权:Privacy - Photo Library Usage Description
  2. 如果相册名称需要根据手机语言环境显示相应语言,需要在Info.plist中设置Localized resources can be mixedYES

后记

如有问题,欢迎给我留言,如果这个工具对你有些帮助,请给我一个star、watch。O(∩_∩)O谢谢

Latest podspec

{
    "name": "MMImagePicker",
    "version": "3.4",
    "summary": "A image picker used on iOS.",
    "homepage": "https://github.com/CheeryLau/MMImagePicker",
    "license": "MIT",
    "authors": {
        "Cheery Lau": "[email protected]"
    },
    "source": {
        "git": "https://github.com/CheeryLau/MMImagePicker.git",
        "tag": "3.4"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "MMImagePicker/**/*.{h,m}",
    "resources": "MMImagePicker/**/MMImagePicker.bundle",
    "frameworks": [
        "Foundation",
        "UIKit",
        "AssetsLibrary"
    ]
}

Pin It on Pinterest

Share This