ZLPhotoBrowser
https://github.com/longitachi/ZLPhotoBrowser
框架整体介绍该框架为一个多选照片(不支持视频)的框架,开题报告,兼容设备开启的iCloud照片存储,并在加载和选择iCloud端照片时做部分细节处理(快速滑动切换图片不会导致图片显示混乱),支持记录历史选择照片。
1.支持多语言国际化(中:简繁, 英,日)
2.支持预览多选(预览图数量及最大多选数可设置)
3.支持直接进入相册多选
4.支持预览大图,大图的缩放等
5.支持实时拍照
6.支持多相册(不同的相册名字)图片混合多选
7.预览已选择照片
8.原图功能
9.可实时监测相册图片变化(即在预览图时,如果会员触发截屏等操作,会实时的加载出该图片)
10.加载iCloud端照片(所有照片加载时都会先加载模糊的图片,然后过渡高清图,iCloud端照片加载更加明显)
框架支持与框架依赖iOS8.0, * (利用arc模式)
XCode8.0, * (需要导入Photos.framework)
注意点如果项目中设置了
[[UINavigationBar appearance] setTranslucent:NO];则需要在ZLDefine.h里 把kViewHeight 修改为
#define kViewHeight [[UIScreen mainScreen] bounds].size.height - 64常用Api/** 最大选择数 default is 10 */ @property (nonatomic, assign) NSInteger maxSelectCount; /** 预览图最大显示数 default is 20 */ @property (nonatomic, assign) NSInteger maxPreviewCount; /** * @brief 显示多选照片视图,带预览效果 * @param sender 调用该控件的视图控制器 * @param animate 是否显示动画效果 * @param lastSelectPhotoModels 已选择的PHAsset,再次调用'showWithSender:animate:lastSelectPhotoModels:completion:'方法之前,可以把上次回调中selectPhotoModels赋值给该属性,便可实现记录上次选择照片的功能,若不需要记录上次选择照片的功能,则该值传nil即可 * @param completion 完成回调 */ - (void)showPreviewPhotoWithSender:(UIViewController *)sender animate:(BOOL)animate lastSelectPhotoModels:(NSArray<ZLSelectPhotoModel *> * _Nullable)lastSelectPhotoModels completion:(void (^)(NSArray<UIImage *> *selectPhotos, NSArray<ZLSelectPhotoModel *> *selectPhotoModels))completion; /** * @brief 显示多选照片视图,直接进入相册选择界面 * 参数含义同上 */ - (void)showPhotoLibraryWithSender:(UIViewController *)sender lastSelectPhotoModels:(NSArray<ZLSelectPhotoModel *> * _Nullable)lastSelectPhotoModels completion:(void (^)(NSArray<UIImage *> *selectPhotos, NSArray<ZLSelectPhotoModel *> *selectPhotoModels))completion; 过期Api//如继续使用该api,论文,将默认调用显示预览视图的效果api - (void)showWithSender:(UIViewController *)sender animate:(BOOL)animate lastSelectPhotoModels:(NSArray<ZLSelectPhotoModel *> * _Nullable)lastSelectPhotoModels completion:(void (^)(NSArray<UIImage *> *selectPhotos, NSArray<ZLSelectPhotoModel *> *selectPhotoModels))completion NS_DEPRECATED(2.0, 2.0, 2.0, 8.0, 'Use - showPreviewPhotoWithSender:animate:lastSelectPhotoModels:completion:');使用方法直接把PhotoBrowser文件夹拖入到您的工程中
Cocoapods安装
pod search ZLPhotoBrowser在项目plist配置文件中添加如下键,值并设为YES
Localized resources can be mixed YES //或者右键plist文件Open As->Source Code 添加 <key>CFBundleAllowMixedLocalizations</key> <true/>#import 'ZLPhotoActionSheet.h' ZLPhotoActionSheet *actionSheet = [[ZLPhotoActionSheet alloc] init]; //设置最大选择数量 actionSheet.maxSelectCount = 5; //设置预览图最大数目 actionSheet.maxPreviewCount = 20; [actionSheet showPreviewPhotoWithSender:self animate:YES lastSelectPhotoModels:self.lastSelectMoldels completion:^(NSArray<UIImage *> * _Nonnull selectPhotos, NSArray<ZLSelectPhotoModel *> * _Nonnull selectPhotoModels) { // your codes... }]; 多语言国际化效果图