123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- //
- // UpImageView.m
- // 乐销
- //
- // Created by 隋林栋 on 2016/12/28.
- // Copyright © 2016年 ping. All rights reserved.
- //
- #import "UpImageView.h"
- @interface UpImageView()
- @end
- @implementation UpImageView
- #pragma mark lazy init
- - (UIView *)upImageBG{
- if (_upImageBG == nil) {
- _upImageBG = [UIControl new];
- _upImageBG.tag = 1;
- _upImageBG.width = SCREEN_WIDTH;
- _upImageBG.clipsToBounds = true;
- // [_upImageBG addTarget:self action:@selector(showImage) forControlEvents:UIControlEventTouchUpInside];
- _upImageBG.widthHeight = XY(SCREEN_WIDTH,W(0));
- _upImageBG.backgroundColor = [UIColor clearColor];
- }
- return _upImageBG;
- }
- - (UIImageView *)upImageHead{
- if (_upImageHead == nil) {
- _upImageHead = [UIImageView new];
- _upImageHead.backgroundColor = [UIColor clearColor];
- _upImageHead.image = [UIImage imageNamed:@"spgl_tp"];
- _upImageHead.widthHeight = XY(W(17),W(17));
- }
- return _upImageHead;
- }
- - (UILabel *)upImageLabel{
- if (_upImageLabel == nil) {
- _upImageLabel = [UILabel new];
- [GlobalMethod setLabel:_upImageLabel widthLimit:0 numLines:0 fontNum:F(14) textColor:COLOR_LABEL text:@"添加图片(选填)"];
- }
- return _upImageLabel;
- }
- - (Collection_Image *)collection_Image{
- if (!_collection_Image) {
- _collection_Image = [Collection_Image new];
- _collection_Image.scrollDirection=UICollectionViewScrollDirectionVertical;
- WEAKSELF
- _collection_Image.blockUpComplete = ^(NSMutableArray *arr) {
- // NSMutableArray *ary = [NSMutableArray new];
- // dispatch_queue_t serialQueue=dispatch_queue_create("串行", DISPATCH_QUEUE_SERIAL);
- // dispatch_sync(serialQueue, ^{
- // for (int i =0; i<arr.count; i++) {
- // XG_AssetModel *model =arr[i];
- // NSLog(@"start %d",i);
- // sleep(i);
- // if (model.isPlaceholder==false) {
- // [[XG_AssetPickerManager manager] getPhotoWithAsset1:model.asset completion:^(UIImage *photo, NSDictionary *info) {
- // [ary addObject:photo];
- // }];
- // }
- // NSLog(@"end %d",i);
- // }
- // });
- // for (XG_AssetModel *model in arr) {
- // if (model.isPlaceholder==false) {
- // [[XG_AssetPickerManager manager] getPhotoWithAsset1:model.asset completion:^(UIImage *photo, NSDictionary *info) {
- // [ary addObject:photo];
- // }];
- // }
- // }
-
- weakSelf.imgArr = arr;
- if (weakSelf.blockResetView != nil) {
- [weakSelf resetView];
- if (weakSelf.blockResetView != nil) {
- weakSelf.blockResetView();
- }
- }
- };
- _collection_Image.blockDelComplete = ^(NSMutableArray *arr) {
- if (arr.count==1) {
- [weakSelf.imgArr removeAllObjects];
- }else{
- [weakSelf.imgArr removeAllObjects];
- weakSelf.imgArr = [NSMutableArray arrayWithCapacity:9];
- for (int j = 0; j < 9; j++) {
- [weakSelf.imgArr addObject:[NSNull null]];
- }
- for (int i =0; i<arr.count; i++) {
- XG_AssetModel *model =arr[i];
- if (model.asset) {
- [[XG_AssetPickerManager manager] getPhotoWithAsset1:model.asset completion:^(UIImage *photo, NSDictionary *info) {
- [weakSelf.imgArr replaceObjectAtIndex:model.number-1 withObject:photo];
- }];
- }
- }
- }
- };
- }
- return _collection_Image;
- }
- - (UILabel *)labelTitle{
- if (_labelTitle == nil) {
- _labelTitle = [UILabel new];
- [GlobalMethod setLabel:_labelTitle widthLimit:0 numLines:0 fontNum:F(16) textColor:COLOR_LABEL text:@""];
- _labelTitle.hidden=true;
- }
- return _labelTitle;
- }
- - (UILabel *)labelName{
- if (_labelName == nil) {
- _labelName = [UILabel new];
- [GlobalMethod setLabel:_labelName widthLimit:0 numLines:0 fontNum:F(14) textColor:COLOR_999 text:@""];
- _labelName.hidden=true;
- }
- return _labelName;
- }
- - (UILabel *)labelTipc{
- if (_labelTipc == nil) {
- _labelTipc = [UILabel new];
- [GlobalMethod setLabel:_labelTipc widthLimit:0 numLines:0 fontNum:F(13) textColor:COLOR_999 text:@""];
- _labelTipc.hidden=true;
- }
- return _labelTipc;
- }
- - (UIView *)backView{
- if (_backView == nil) {
- _backView = [UIView new];
- _backView.backgroundColor = COLOR_ADDRESS;
- [GlobalMethod setRoundView:_backView color:COLOR_ADDRESS numRound:5 width:0];
- _backView.hidden=true;
- }
- return _backView;
- }
- #pragma mark 初始化
- - (instancetype)init{
- self = [super init];
- if (self) {
- self.backgroundColor = [UIColor clearColor];
- self.width = SCREEN_WIDTH;
- self.isHiddenCollectionNoData = true;
- [self addSubview];
- }
- return self;
- }
- #pragma mark addSubView
- - (void)addSubview{
- [self addSubview:self.upImageBG];
- [self.upImageBG addSubview:self.upImageHead];
- [self.upImageBG addSubview:self.upImageLabel];
- [self addSubview:self.labelTitle];
- [self addSubview:self.labelName];
- [self addSubview:self.backView];
- [self.backView addSubview:self.labelTipc];
- [self addSubview:self.collection_Image];
-
- [self resetView];
- }
- - (void)resetView{
- [self removeSubViewWithTag:TAG_LINE];
- //see up image
- self.upImageBG.hidden = self.isNotShowUpImageView;
- self.collection_Image.hidden = true;
-
-
- if (self.isNotShowFileView) {
- self.labelTitle.hidden=false;
- self.labelName.hidden=false;
- self.backView.hidden=false;
- self.labelTipc.hidden=false;
-
- [self.labelTitle fitTitle:@"其他资质" variable:0];
- self.labelTitle.leftTop = XY(W(15),W(15));
- [self.labelName fitTitle:@"请上传你的其他认证资质(如需认证特定内容)" variable:0];
- self.labelName.leftTop = XY(W(15),self.labelTitle.bottom+W(10));
- self.collection_Image.top = self.labelName.bottom+W(10);
- self.collection_Image.left = W(5);
- self.collection_Image.hidden = self.collection_Image.aryDatas.count <= 0 && self.isHiddenCollectionNoData;
- if (self.isCreat) {
- _collection_Image.assets = self.assets;
- }
- [self.collection_Image resetView];
-
- self.backView.widthHeight = XY(SCREEN_WIDTH-W(30), W(100));
- self.backView.leftTop = XY(W(15),W(10)+self.collection_Image.aryDatas.count == 0 && self.isHiddenCollectionNoData?self.upImageBG.bottom:self.collection_Image.bottom);
- [self.labelTipc fitTitle:@"用户名称、认证信息需体现特定内容,请提供对应资质。 例如:网站需提供ICP备案查询截图、商标需提供商标注册证、手机应用需提供软件著作权证、游戏需提供版号、其他品牌授权文件等。" variable:self.backView.width-W(20)];
- self.labelTipc.leftTop = XY(W(10),W(10));
-
- self.backView.height = self.labelTipc.bottom+W(10);
- self.height = self.backView.bottom+W(10);
-
- }else{
- //up image top view
- self.upImageHead.leftTop = XY(W(15),W(15));
- self.upImageLabel.leftCenterY = XY(W(15),self.upImageHead.centerY);
- self.upImageBG.height = self.isNotShowUpImageTopView ? 0 : self.upImageHead.bottom + W(15);
-
- self.collection_Image.top = self.upImageBG.bottom;
- self.collection_Image.left = W(5);
- self.collection_Image.hidden = self.collection_Image.aryDatas.count <= 0 && self.isHiddenCollectionNoData;
- if (self.isCreat) {
- _collection_Image.assets = self.assets;
- }
- _collection_Image.imgName=self.imgName;
- [self.collection_Image resetView];
- self.height = self.collection_Image.aryDatas.count == 0 && self.isHiddenCollectionNoData?self.upImageBG.bottom:self.collection_Image.bottom;
- }
- }
- #pragma mark 显示图片
- - (void)showImage{
- [self.collection_Image showSelectImage];
- }
- #pragma mark 销毁
- - (void)dealloc{
- NSLog(@"%s %@",__func__,self.class);
- }
- @end
|