JXCategoryTitleBackgroundView.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // JXCategoryTitleBackgroundView.m
  3. // JXCategoryView
  4. //
  5. // Created by jiaxin on 2019/8/16.
  6. // Copyright © 2019 jiaxin. All rights reserved.
  7. //
  8. #import "JXCategoryTitleBackgroundView.h"
  9. @implementation JXCategoryTitleBackgroundView
  10. - (void)initializeData {
  11. [super initializeData];
  12. self.cellWidthIncrement = 20;
  13. self.normalBackgroundColor = [UIColor lightGrayColor];
  14. self.normalBorderColor = [UIColor clearColor];
  15. self.selectedBackgroundColor = [[UIColor orangeColor] colorWithAlphaComponent:0.3];
  16. self.selectedBorderColor = [UIColor orangeColor];
  17. self.borderLineWidth = 1;
  18. self.backgroundCornerRadius = 3;
  19. self.backgroundWidth = JXCategoryViewAutomaticDimension;
  20. self.backgroundHeight = 25;
  21. }
  22. //返回自定义的cell class
  23. - (Class)preferredCellClass {
  24. return [JXCategoryTitleBackgroundCell class];
  25. }
  26. - (void)refreshDataSource {
  27. NSMutableArray *tempArray = [NSMutableArray array];
  28. for (int i = 0; i < self.titles.count; i++) {
  29. JXCategoryTitleBackgroundCellModel *cellModel = [[JXCategoryTitleBackgroundCellModel 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. JXCategoryTitleBackgroundCellModel *myModel = (JXCategoryTitleBackgroundCellModel *)cellModel;
  37. myModel.normalBackgroundColor = self.normalBackgroundColor;
  38. myModel.normalBorderColor = self.normalBorderColor;
  39. myModel.selectedBackgroundColor = self.selectedBackgroundColor;
  40. myModel.selectedBorderColor = self.selectedBorderColor;
  41. myModel.borderLineWidth = self.borderLineWidth;
  42. myModel.backgroundCornerRadius = self.backgroundCornerRadius;
  43. myModel.backgroundWidth = self.backgroundWidth;
  44. myModel.backgroundHeight = self.backgroundHeight;
  45. }
  46. @end