RQHomeSubPageSortCell.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // RQHomeSubPageSortCell.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/5.
  6. //
  7. #import "RQHomeSubPageSortCell.h"
  8. @interface RQHomeSubPageSortCell ()
  9. @property (nonatomic, readwrite, strong) RQHomeSubPageSortItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIView *myContentView;
  11. @property (weak, nonatomic) IBOutlet UILabel *myTitleLabel;
  12. @end
  13. @implementation RQHomeSubPageSortCell
  14. #pragma mark - Public Method
  15. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  16. static NSString *ID = @"RQHomeSubPageSortCell";
  17. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  18. RQHomeSubPageSortCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  19. if (!cell) cell = [self rq_viewFromXib];
  20. cell.layer.shadowColor = [UIColor colorWithHexString:@"#7C8188" alpha:0.2f].CGColor;
  21. [cell.numBtn setBackgroundImage:[UIImage imageWithColor:RQ_MAIN_COLOR] forState:UIControlStateNormal];
  22. [cell.numBtn setBackgroundImage:[UIImage imageWithColor:RQ_MAIN_TEXT_COLOR_RED] forState:UIControlStateSelected];
  23. return cell;
  24. }
  25. - (void)bindViewModel:(RQHomeSubPageSortItemViewModel *)viewModel {
  26. _viewModel = viewModel;
  27. NSString *title = viewModel.title;
  28. if([title containsString:@","]){
  29. title = [[title componentsSeparatedByString:@","] firstObject];
  30. }
  31. _myTitleLabel.text = title;
  32. _numBtn.imageView.size = _numBtn.size;
  33. [_numBtn setTitle:viewModel.serialNumberStr forState:UIControlStateNormal];
  34. _numBtn.selected = [viewModel.serialNumberStr isEqualToString:@"地"] || [title containsString:@"必"] || [viewModel.serialNumberStr isEqualToString:@"新"];
  35. }
  36. #pragma mark - SystemMethod
  37. - (void)awakeFromNib {
  38. [super awakeFromNib];
  39. }
  40. @end