JXCategoryDotView.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // JXCategoryDotView.m
  3. // JXCategoryView
  4. //
  5. // Created by jiaxin on 2018/8/20.
  6. // Copyright © 2018年 jiaxin. All rights reserved.
  7. //
  8. #import "JXCategoryDotView.h"
  9. @implementation JXCategoryDotView
  10. - (void)initializeData {
  11. [super initializeData];
  12. _relativePosition = JXCategoryDotRelativePosition_TopRight;
  13. _dotSize = CGSizeMake(10, 10);
  14. _dotCornerRadius = JXCategoryViewAutomaticDimension;
  15. _dotColor = [UIColor redColor];
  16. _dotOffset = CGPointZero;
  17. }
  18. - (Class)preferredCellClass {
  19. return [JXCategoryDotCell class];
  20. }
  21. - (void)refreshDataSource {
  22. NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:self.titles.count];
  23. for (int i = 0; i < self.titles.count; i++) {
  24. JXCategoryDotCellModel *cellModel = [[JXCategoryDotCellModel alloc] init];
  25. [tempArray addObject:cellModel];
  26. }
  27. self.dataSource = [NSArray arrayWithArray:tempArray];
  28. }
  29. - (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index {
  30. [super refreshCellModel:cellModel index:index];
  31. JXCategoryDotCellModel *myCellModel = (JXCategoryDotCellModel *)cellModel;
  32. myCellModel.dotHidden = [self.dotStates[index] boolValue];
  33. myCellModel.relativePosition = self.relativePosition;
  34. myCellModel.dotSize = self.dotSize;
  35. myCellModel.dotColor = self.dotColor;
  36. myCellModel.dotOffset = self.dotOffset;
  37. if (self.dotCornerRadius == JXCategoryViewAutomaticDimension) {
  38. myCellModel.dotCornerRadius = self.dotSize.height/2;
  39. }else {
  40. myCellModel.dotCornerRadius = self.dotCornerRadius;
  41. }
  42. }
  43. @end