猎豆优选

CPFindIconView.m 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // CPFindIconView.m
  3. // CAIPU
  4. //
  5. // Created by 小花 on 2018/4/4.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "CPFindIconView.h"
  9. @interface CPFindIconView ()
  10. @property (nonatomic, strong) NSMutableArray *views;
  11. @property (nonatomic, strong) UILabel *text;
  12. @end
  13. @implementation CPFindIconView
  14. - (instancetype)init {
  15. self = [super init];
  16. if (self) {
  17. [self initUI];
  18. }
  19. return self;
  20. }
  21. - (void)initUI {
  22. CGFloat width = Fitsize(24);
  23. CGFloat height = width;
  24. CGFloat marginLeft = -Fitsize(8);
  25. UIImageView *lastImgView;
  26. for (int i = 0; i < 7; i++) {
  27. UIImageView *icon = [[UIImageView alloc] init];
  28. icon.frame = CGRectMake((width+marginLeft)*i, Fitsize(8), width, height);
  29. icon.layer.cornerRadius = FITSIZE(12);
  30. icon.backgroundColor = [UIColor yhGrayColor];
  31. icon.clipsToBounds = YES;
  32. icon.layer.borderWidth = 1;
  33. icon.layer.borderColor = [UIColor yhGrayColor].CGColor;
  34. [self addSubview:icon];
  35. [self.views addObject:icon];
  36. if (i == 6) {
  37. lastImgView = icon;
  38. }
  39. }
  40. // SPScrollNumLabel *label = [[SPScrollNumLabel alloc] init];
  41. // label.frame = CGRectMake(0, 0, 150, height);
  42. // label.font = [UIFont systemFontOfSize:12];
  43. // label.textColor = [UIColor YHColorWithHex:0x666666];
  44. // [self addSubview:label];
  45. // self.upCountLabel = label;
  46. // label.centerY = Fitsize(20);
  47. // [self.views addObject:label];
  48. UILabel *text = [[UILabel alloc] init];
  49. text.frame = CGRectMake(lastImgView.right+10, 0, 150, height);
  50. text.font = [UIFont systemFontOfSize:12];
  51. text.textColor = [UIColor YHColorWithHex:0x666666];
  52. text.text = @"已有--人分享";
  53. text.centerY = Fitsize(20);
  54. self.text = text;
  55. [self addSubview:text];
  56. }
  57. - (void)setUpCountIncreaseOne {
  58. [self.upCountLabel increaseNumber:1];
  59. }
  60. - (void)setUpCountReduceOne {
  61. [self.upCountLabel decreaseNumber:1];
  62. }
  63. - (void)configViewWithIcons:(NSArray *)icons upCount:(NSString *)upCount {
  64. // for (int i = 0; i < 5; i++) {
  65. // UIImageView *imageView = self.views[i];
  66. // if (i >= icons.count) {
  67. // imageView.hidden = YES;
  68. // }else {
  69. // imageView.hidden = NO;
  70. // [imageView sd_setImageWithURL:[NSURL URLWithString:icons[i]] placeholderImage:Placehold_Img];
  71. //
  72. // }
  73. // }
  74. self.text.text = [NSString stringWithFormat:@"已有%@人分享",upCount];
  75. //反向
  76. NSMutableArray *iconArr = [[NSMutableArray alloc] initWithArray:icons];
  77. NSArray* reversedArray = [[iconArr reverseObjectEnumerator] allObjects];
  78. for (int i = 0; i < 7; i++) {
  79. if (i>icons.count-1) {
  80. return;
  81. }
  82. UIImageView *imageView = self.views[i];
  83. [imageView sd_setFadeImageWithURL:[NSURL URLWithString:reversedArray[i]] placeholderImage:[UIImage imageNamed:@"unlogin"] options:0 progress:nil completed:nil];
  84. }
  85. }
  86. - (NSMutableArray *)views {
  87. if (!_views) {
  88. _views = [NSMutableArray array];
  89. }
  90. return _views;
  91. }
  92. @end