口袋优选

KBSignInView.m 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // KBSignInView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/9/27.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBSignInView.h"
  9. #import "KBSignInModel.h"
  10. @interface KBSignInView ()
  11. @property (nonatomic, strong) NSMutableArray *imgArray;
  12. @property (nonatomic, strong) NSMutableArray *lineArray;
  13. @end
  14. @implementation KBSignInView
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. CGFloat imgViewX= (FITSIZE(323)-20*7-16*2)/6;
  19. self.imgArray = [NSMutableArray arrayWithCapacity:0];
  20. self.lineArray = [NSMutableArray arrayWithCapacity:0];
  21. for (int i = 0; i < 7; i++) {
  22. UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(16+imgViewX*i+i*20, 0, 20, 20)];
  23. imgView.backgroundColor=[UIColor clearColor];
  24. // imgView.image = [UIImage imageNamed:@"noSignIn"];
  25. [self addSubview:imgView];
  26. [self.imgArray addObject:imgView];
  27. if (i>0) {
  28. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(16+i*20+imgViewX*(i-1), 9, imgViewX, 2)];
  29. [self addSubview:line];
  30. // line.backgroundColor = [UIColor colorWithHexString:@"#EF4D2D"];
  31. [self.lineArray addObject:line];
  32. }
  33. }
  34. }
  35. return self;
  36. }
  37. - (void)setSignModelArr:(NSArray *)array {
  38. for (int i=0; i<self.imgArray.count; i++) {
  39. UIImageView *imgView = self.imgArray[i];
  40. if (i < array.count) {
  41. KBSignDaysModel *model = [KBSignDaysModel yy_modelWithJSON:array[i]];
  42. switch (model.type) {
  43. case 0:
  44. imgView.image = [UIImage imageNamed:@"noSignIn"];
  45. if (i>0) {
  46. UIView *line = self.lineArray[i-1];
  47. line.backgroundColor = [UIColor colorWithHexString:@"#F9B37F"];
  48. }
  49. break;
  50. case 1:
  51. imgView.image = [UIImage imageNamed:@"haveSignIn"];
  52. if (i>0) {
  53. UIView *line = self.lineArray[i-1];
  54. line.backgroundColor = [UIColor colorWithHexString:@"#EF4D2D"];
  55. }
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61. }
  62. }
  63. - (NSMutableArray *)imgArray {
  64. if (!_imgArray) {
  65. _imgArray = [NSMutableArray array];
  66. }
  67. return _imgArray;
  68. }
  69. @end