// // CPFindIconView.m // CAIPU // // Created by 小花 on 2018/4/4. // Copyright © 2018年 kuxuan. All rights reserved. // #import "CPFindIconView.h" @interface CPFindIconView () @property (nonatomic, strong) NSMutableArray *views; @property (nonatomic, strong) UILabel *text; @end @implementation CPFindIconView - (instancetype)init { self = [super init]; if (self) { [self initUI]; } return self; } - (void)initUI { CGFloat width = Fitsize(24); CGFloat height = width; CGFloat marginLeft = -Fitsize(8); UIImageView *lastImgView; for (int i = 0; i < 7; i++) { UIImageView *icon = [[UIImageView alloc] init]; icon.frame = CGRectMake((width+marginLeft)*i, Fitsize(8), width, height); icon.layer.cornerRadius = FITSIZE(12); icon.backgroundColor = [UIColor yhGrayColor]; icon.clipsToBounds = YES; icon.layer.borderWidth = 1; icon.layer.borderColor = [UIColor yhGrayColor].CGColor; [self addSubview:icon]; [self.views addObject:icon]; if (i == 6) { lastImgView = icon; } } // SPScrollNumLabel *label = [[SPScrollNumLabel alloc] init]; // label.frame = CGRectMake(0, 0, 150, height); // label.font = [UIFont systemFontOfSize:12]; // label.textColor = [UIColor YHColorWithHex:0x666666]; // [self addSubview:label]; // self.upCountLabel = label; // label.centerY = Fitsize(20); // [self.views addObject:label]; UILabel *text = [[UILabel alloc] init]; text.frame = CGRectMake(lastImgView.right+10, 0, 150, height); text.font = [UIFont systemFontOfSize:12]; text.textColor = [UIColor YHColorWithHex:0x666666]; text.text = @"已有--人分享"; text.centerY = Fitsize(20); self.text = text; [self addSubview:text]; } - (void)setUpCountIncreaseOne { [self.upCountLabel increaseNumber:1]; } - (void)setUpCountReduceOne { [self.upCountLabel decreaseNumber:1]; } - (void)configViewWithIcons:(NSArray *)icons upCount:(NSString *)upCount { // for (int i = 0; i < 5; i++) { // UIImageView *imageView = self.views[i]; // if (i >= icons.count) { // imageView.hidden = YES; // }else { // imageView.hidden = NO; // [imageView sd_setImageWithURL:[NSURL URLWithString:icons[i]] placeholderImage:Placehold_Img]; // // } // } self.text.text = [NSString stringWithFormat:@"已有%@人分享",upCount]; //反向 NSMutableArray *iconArr = [[NSMutableArray alloc] initWithArray:icons]; NSArray* reversedArray = [[iconArr reverseObjectEnumerator] allObjects]; for (int i = 0; i < 7; i++) { if (i>icons.count-1) { return; } UIImageView *imageView = self.views[i]; [imageView sd_setFadeImageWithURL:[NSURL URLWithString:reversedArray[i]] placeholderImage:[UIImage imageNamed:@"unlogin"] options:0 progress:nil completed:nil]; } } - (NSMutableArray *)views { if (!_views) { _views = [NSMutableArray array]; } return _views; } @end