62 lines
2.1 KiB
Objective-C
62 lines
2.1 KiB
Objective-C
//
|
|
// JXCategoryNumberView.m
|
|
// DQGuess
|
|
//
|
|
// Created by jiaxin on 2018/4/9.
|
|
// Copyright © 2018年 jingbo. All rights reserved.
|
|
//
|
|
|
|
#import "JXCategoryNumberView.h"
|
|
|
|
@implementation JXCategoryNumberView
|
|
|
|
- (void)dealloc {
|
|
self.numberStringFormatterBlock = nil;
|
|
}
|
|
|
|
- (void)initializeData {
|
|
[super initializeData];
|
|
|
|
self.cellSpacing = 25;
|
|
_numberTitleColor = [UIColor whiteColor];
|
|
_numberBackgroundColor = [UIColor colorWithRed:241/255.0 green:147/255.0 blue:95/255.0 alpha:1];
|
|
_numberLabelHeight = 14;
|
|
_numberLabelWidthIncrement = 10;
|
|
_numberLabelFont = [UIFont systemFontOfSize:11];
|
|
_shouldMakeRoundWhenSingleNumber = NO;
|
|
}
|
|
|
|
- (Class)preferredCellClass {
|
|
return [JXCategoryNumberCell class];
|
|
}
|
|
|
|
- (void)refreshDataSource {
|
|
NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:self.titles.count];
|
|
for (int i = 0; i < self.titles.count; i++) {
|
|
JXCategoryNumberCellModel *cellModel = [[JXCategoryNumberCellModel alloc] init];
|
|
[tempArray addObject:cellModel];
|
|
}
|
|
self.dataSource = [NSArray arrayWithArray:tempArray];
|
|
}
|
|
|
|
- (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index {
|
|
[super refreshCellModel:cellModel index:index];
|
|
|
|
JXCategoryNumberCellModel *myCellModel = (JXCategoryNumberCellModel *)cellModel;
|
|
myCellModel.count = [self.counts[index] integerValue];
|
|
if (self.numberStringFormatterBlock != nil) {
|
|
myCellModel.numberString = self.numberStringFormatterBlock(myCellModel.count);
|
|
}else {
|
|
myCellModel.numberString = [NSString stringWithFormat:@"%ld", (long)myCellModel.count];
|
|
}
|
|
myCellModel.numberBackgroundColor = self.numberBackgroundColor;
|
|
myCellModel.numberTitleColor = self.numberTitleColor;
|
|
myCellModel.numberLabelHeight = self.numberLabelHeight;
|
|
myCellModel.numberLabelOffset = self.numberLabelOffset;
|
|
myCellModel.numberLabelWidthIncrement = self.numberLabelWidthIncrement;
|
|
myCellModel.numberLabelFont = self.numberLabelFont;
|
|
myCellModel.shouldMakeRoundWhenSingleNumber = self.shouldMakeRoundWhenSingleNumber;
|
|
}
|
|
|
|
@end
|