// // RQHomeSubPageSortCell.m // SDJK // // Created by 张嵘 on 2021/8/5. // #import "RQHomeSubPageSortCell.h" @interface RQHomeSubPageSortCell () @property (nonatomic, readwrite, strong) RQHomeSubPageSortItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIView *myContentView; @property (weak, nonatomic) IBOutlet UILabel *myTitleLabel; @end @implementation RQHomeSubPageSortCell #pragma mark - Public Method + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQHomeSubPageSortCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQHomeSubPageSortCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; cell.layer.shadowColor = [UIColor colorWithHexString:@"#7C8188" alpha:0.2f].CGColor; [cell.numBtn setBackgroundImage:[UIImage imageWithColor:RQ_MAIN_COLOR] forState:UIControlStateNormal]; [cell.numBtn setBackgroundImage:[UIImage imageWithColor:RQ_MAIN_TEXT_COLOR_RED] forState:UIControlStateSelected]; return cell; } - (void)bindViewModel:(RQHomeSubPageSortItemViewModel *)viewModel { _viewModel = viewModel; NSString *title = viewModel.title; if([title containsString:@","]){ title = [[title componentsSeparatedByString:@","] firstObject]; } _myTitleLabel.text = title; _numBtn.imageView.size = _numBtn.size; [_numBtn setTitle:viewModel.serialNumberStr forState:UIControlStateNormal]; _numBtn.selected = [viewModel.serialNumberStr isEqualToString:@"地"] || [title containsString:@"必"] || [viewModel.serialNumberStr isEqualToString:@"新"]; } #pragma mark - SystemMethod - (void)awakeFromNib { [super awakeFromNib]; } @end