NYBlockExerciseHeaderView.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // NYBlockExerciseHeaderView.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2024/12/5.
  6. // Copyright © 2024 JCZ. All rights reserved.
  7. //
  8. #import "NYBlockExerciseHeaderView.h"
  9. @interface NYBlockExerciseHeaderView ()
  10. @property (nonatomic, readwrite, strong) NYBlockExerciseGroupViewModel *viewModel;
  11. @end
  12. @implementation NYBlockExerciseHeaderView
  13. + (instancetype)reusableViewWithCollectionView:(UICollectionView *)collectionView OfKind:(NSString *)elementKind forIndexPath:(NSIndexPath *)indexPath {
  14. NSString *ID = [NSString stringWithFormat:@"%@%@", @"NYBlockExerciseHeaderView",elementKind];
  15. [collectionView registerNib:[UINib nibWithNibName:@"NYBlockExerciseHeaderView" bundle:nil] forSupplementaryViewOfKind:elementKind withReuseIdentifier:ID];
  16. NYBlockExerciseHeaderView *reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:elementKind withReuseIdentifier:ID forIndexPath:indexPath];
  17. if (!reusableView) reusableView = [self rq_viewFromXib];
  18. return reusableView;
  19. }
  20. - (void)bindViewModel:(NYBlockExerciseGroupViewModel *)viewModel {
  21. self.viewModel = viewModel;
  22. self.name_label.text = viewModel.header;
  23. self.des_label.text = viewModel.headerDesStr;
  24. if(viewModel.star>0){
  25. for(int i=0;i<viewModel.star;i++){
  26. UIButton *btn = [self.stars_view viewWithTag:10+i];
  27. btn.selected = YES;
  28. }
  29. }
  30. }
  31. - (void)awakeFromNib {
  32. [super awakeFromNib];
  33. // Initialization code
  34. }
  35. @end