JXCategoryNumberView.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. self.numberStringFormatterBlock = nil;
  12. }
  13. - (void)initializeData {
  14. [super initializeData];
  15. self.cellSpacing = 25;
  16. _numberTitleColor = [UIColor whiteColor];
  17. _numberBackgroundColor = [UIColor colorWithRed:241/255.0 green:147/255.0 blue:95/255.0 alpha:1];
  18. _numberLabelHeight = 14;
  19. _numberLabelWidthIncrement = 10;
  20. _numberLabelFont = [UIFont systemFontOfSize:11];
  21. _shouldMakeRoundWhenSingleNumber = NO;
  22. }
  23. - (Class)preferredCellClass {
  24. return [JXCategoryNumberCell class];
  25. }
  26. - (void)refreshDataSource {
  27. NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:self.titles.count];
  28. for (int i = 0; i < self.titles.count; i++) {
  29. JXCategoryNumberCellModel *cellModel = [[JXCategoryNumberCellModel alloc] init];
  30. [tempArray addObject:cellModel];
  31. }
  32. self.dataSource = [NSArray arrayWithArray: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. myCellModel.shouldMakeRoundWhenSingleNumber = self.shouldMakeRoundWhenSingleNumber;
  50. }
  51. @end