SelectImageHandler.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // SelectImageHandler.h
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/1/7.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. // 此类只处理本地图片的选择和浏览 视频和gif图片没有添加处理方法
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @protocol SelectImageHandlerDelegate <NSObject>
  11. @optional
  12. /// 选择回调
  13. - (void)didFinishPickingPhotos:(NSArray<UIImage *>*)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto;
  14. /// 预览回调
  15. - (void)previewImageDidFinishPhotos:(NSArray<UIImage *>*)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto;
  16. @end
  17. @interface SelectImageHandler : NSObject
  18. @property (nonatomic, readwrite, weak) id<SelectImageHandlerDelegate>delegate;
  19. /// 父控制器
  20. @property (nonatomic, readwrite, strong) UIViewController *parentController;
  21. /// Default is 9 / 默认最大可选9张图片
  22. @property (nonatomic, readwrite, assign) NSInteger maxImagesCount;
  23. #pragma mark — ------单选模式------
  24. /// 单选模式,maxImagesCount为1时才生效
  25. @property (nonatomic, assign) BOOL showSelectBtn; ///< 在单选模式下,照片列表页中,显示选择按钮,默认为NO
  26. @property (nonatomic, assign) BOOL allowCrop; ///< 允许裁剪,默认为YES,showSelectBtn为NO才生效
  27. /// 是否圆形裁剪 默认NO不进行圆形裁剪 只有allowCropSwitch为YES时才有效
  28. @property (nonatomic, readwrite, assign) BOOL needCircleCrop;
  29. /// 是否正方形裁剪
  30. @property (nonatomic, assign) BOOL allowSquareCrop;
  31. /// 是否横图裁剪
  32. @property (nonatomic, assign) BOOL allowHorizontalCrop;
  33. #pragma mark — ------单选模式------
  34. /// 显示图片选择控制器
  35. /// @param maxCount 能选择的最大数量
  36. /// @param parentController 父控制器且支持代理
  37. - (void)showImagePickerControllerWithMaxCount:(NSInteger)maxCount parentController:(UIViewController*)parentController;
  38. /// 预览图片
  39. /// @param selectedPhotos 选中的图片数组
  40. /// @param selectedAssets 选中图片数组的相册数据
  41. /// @param index 选中的索引
  42. /// @param parentController 父控制器
  43. - (void)previewImagePickerWithSelectedPhotos:(NSArray *)selectedPhotos selectedAssets:(NSArray *)selectedAssets index:(NSInteger)index parentController:(UIViewController*)parentController;
  44. @end
  45. NS_ASSUME_NONNULL_END