选图组件视觉与交互封装

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

效果图

依赖

暂未加入 AntUI 基线

接口说明

@protocol AUImagePickerDataProtocol <NSObject>

- (UIImage *)image;

@end

@interface AUImagePickerSkeleton : UIView

- (AUImagePickerSkeleton *)initWithTitle:(NSString *)title
               maxNumberOfImages:(NSUInteger)maxNumberOfImages;

@property(nonatomic, assign, readonly) NSUInteger maxNumberOfImages;
@property(nonatomic, weak) id<AUImagePickerDelegate> delegate;
@property(nonatomic, strong, readonly) NSArray<id<AUImagePickerDataProtocol>> *imagePickerDatas;

- (void)updateImagePickerDatas:(NSArray <id<AUImagePickerDataProtocol>>*) datas;

@end

@protocol AUImagePickerDelegate <NSObject>

@required
- (void)imagePickerAddButtonClick:(AUImagePickerSkeleton *)imagePicker;

@optional
- (void)imagePickerImageClick:(AUImagePickerSkeleton *)imagePicker
                   clickData:(id<AUImagePickerDataProtocol>)clickData;
@end

代码示例

- (void)viewDidLoad {
    [super viewDidLoad];
    self.datas = [[NSMutableArray alloc] init];
    self.picker = [[AUImagePickerSkeleton alloc] initWithTitle:@"图片(选填,上传问题截图)" maxNumberOfImages:4];
    self.picker.top = 100;
    self.picker.delegate = self;
    [self.view addSubview:self.picker];
    [self.view addSubview:self.button];
    self.view.backgroundColor = RGB(0xEBEBEB);
}

- (void)imagePickerAddButtonClick:(AUImagePickerSkeleton *)imagePicker
{
    AUImagePickerData *data = [AUImagePickerData new];
    data.originalImage = [self getImageWithCount:[self.datas count]];
    [self.datas addObject:data];
    [self updatePickerAndResize];
}

-(void)imagePickerImageClick:(AUImagePickerSkeleton *)imagePicker
                   clickData:(id<AUImagePickerDataProtocol>)clickData
{
    NSString *msg = @"";
    if ([self.datas containsObject:clickData]) {
        msg = [NSString stringWithFormat:@"点击第%d张图片",(int)[self.datas indexOfObject:clickData]+1];
    }else{
        msg = @"点击的图片发生异常";
    }
    [AUToast presentModalToastWithin:self.view
                            withIcon:AUToastIconNone
                                text:msg
                            duration:1
                              logTag:@"demo"
                          completion:NULL];

}