JXCategoryNumberView.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // JXCategoryNumberView.m
  3. // DQGuess
  4. //
  5. // Created by jiaxin on 2018/4/9.
  6. // Copyright © 2018年 jingbo. All rights reserved.
  7. //
  8. #import "JXCategoryNumberView.h"
  9. @implementation JXCategoryNumberView
  10. - (void)dealloc
  11. {
  12. self.numberStringFormatterBlock = nil;
  13. }
  14. - (void)initializeData {
  15. [super initializeData];
  16. self.cellSpacing = 25;
  17. _numberTitleColor = [UIColor whiteColor];
  18. _numberBackgroundColor = [UIColor colorWithRed:241/255.0 green:147/255.0 blue:95/255.0 alpha:1];
  19. _numberLabelHeight = 14;
  20. _numberLabelWidthIncrement = 10;
  21. _numberLabelFont = [UIFont systemFontOfSize:11];
  22. }
  23. - (Class)preferredCellClass {
  24. return [JXCategoryNumberCell class];
  25. }
  26. - (void)refreshDataSource {
  27. NSMutableArray *tempArray = [NSMutableArray array];
  28. for (int i = 0; i < self.titles.count; i++) {
  29. JXCategoryNumberCellModel *cellModel = [[JXCategoryNumberCellModel alloc] init];
  30. [tempArray addObject:cellModel];
  31. }
  32. self.dataSource = tempArray;
  33. }
  34. - (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index {
  35. [super refreshCellModel:cellModel index:index];
  36. JXCategoryNumberCellModel *myCellModel = (JXCategoryNumberCellModel *)cellModel;
  37. myCellModel.count = [self.counts[index] integerValue];
  38. if (self.numberStringFormatterBlock != nil) {
  39. myCellModel.numberString = self.numberStringFormatterBlock(myCellModel.count);
  40. }else {
  41. myCellModel.numberString = [NSString stringWithFormat:@"%ld", (long)myCellModel.count];
  42. }
  43. myCellModel.numberBackgroundColor = self.numberBackgroundColor;
  44. myCellModel.numberTitleColor = self.numberTitleColor;
  45. myCellModel.numberLabelHeight = self.numberLabelHeight;
  46. myCellModel.numberLabelOffset = self.numberLabelOffset;
  47. myCellModel.numberLabelWidthIncrement = self.numberLabelWidthIncrement;
  48. myCellModel.numberLabelFont = self.numberLabelFont;
  49. }
  50. @end