全部产品

选图组件视觉与交互封装

更新时间:2019-09-26 18:40:20

  • AUImagePickerSkeleton 是选图组件视觉与交互的封装,不包括调用相册、浏览、上传功能。
  • 目前暂无完整的选图功能,后续会在 BEEViews 中增加继承了功能的组件。

效果图

依赖

  1. 暂未加入AntUI基线

接口说明

  1. @protocol AUImagePickerDataProtocol <NSObject>
  2. - (UIImage *)image;
  3. @end
  4. @interface AUImagePickerSkeleton : UIView
  5. - (AUImagePickerSkeleton *)initWithTitle:(NSString *)title
  6. maxNumberOfImages:(NSUInteger)maxNumberOfImages;
  7. @property(nonatomic, assign, readonly) NSUInteger maxNumberOfImages;
  8. @property(nonatomic, weak) id<AUImagePickerDelegate> delegate;
  9. @property(nonatomic, strong, readonly) NSArray<id<AUImagePickerDataProtocol>> *imagePickerDatas;
  10. - (void)updateImagePickerDatas:(NSArray <id<AUImagePickerDataProtocol>>*) datas;
  11. @end
  12. @protocol AUImagePickerDelegate <NSObject>
  13. @required
  14. - (void)imagePickerAddButtonClick:(AUImagePickerSkeleton *)imagePicker;
  15. @optional
  16. - (void)imagePickerImageClick:(AUImagePickerSkeleton *)imagePicker
  17. clickData:(id<AUImagePickerDataProtocol>)clickData;
  18. @end

代码示例

  1. - (void)viewDidLoad {
  2. [super viewDidLoad];
  3. self.datas = [[NSMutableArray alloc] init];
  4. self.picker = [[AUImagePickerSkeleton alloc] initWithTitle:@"图片(选填,上传问题截图)" maxNumberOfImages:4];
  5. self.picker.top = 100;
  6. self.picker.delegate = self;
  7. [self.view addSubview:self.picker];
  8. [self.view addSubview:self.button];
  9. self.view.backgroundColor = RGB(0xEBEBEB);
  10. }
  11. - (void)imagePickerAddButtonClick:(AUImagePickerSkeleton *)imagePicker
  12. {
  13. AUImagePickerData *data = [AUImagePickerData new];
  14. data.originalImage = [self getImageWithCount:[self.datas count]];
  15. [self.datas addObject:data];
  16. [self updatePickerAndResize];
  17. }
  18. -(void)imagePickerImageClick:(AUImagePickerSkeleton *)imagePicker
  19. clickData:(id<AUImagePickerDataProtocol>)clickData
  20. {
  21. NSString *msg = @"";
  22. if ([self.datas containsObject:clickData]) {
  23. msg = [NSString stringWithFormat:@"点击第%d张图片",(int)[self.datas indexOfObject:clickData]+1];
  24. }else{
  25. msg = @"点击的图片发生异常";
  26. }
  27. [AUToast presentModalToastWithin:self.view
  28. withIcon:AUToastIconNone
  29. text:msg
  30. duration:1
  31. logTag:@"demo"
  32. completion:NULL];
  33. }