RQCommonBannerADCell.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // RQCommonBannerADCell.m
  3. // NiuBi
  4. //
  5. // Created by 张嵘 on 2023/2/20.
  6. //
  7. #import "RQCommonBannerADCell.h"
  8. @interface RQCommonBannerADCell () <SDCycleScrollViewDelegate>
  9. @property (nonatomic, readwrite, strong) RQCommonBannerADItemViewModel *viewModel;
  10. @property (nonatomic, readwrite, strong) SDCycleScrollView *sdcycleScrollView;
  11. @end
  12. @implementation RQCommonBannerADCell
  13. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  14. static NSString *ID = @"RQCommonBannerADCell";
  15. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  16. RQCommonBannerADCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  17. if (!cell) cell = [self rq_viewFromXib];
  18. return cell;
  19. }
  20. - (void)bindViewModel:(RQCommonBannerADItemViewModel *)viewModel {
  21. _viewModel = viewModel;
  22. }
  23. - (void)awakeFromNib {
  24. [super awakeFromNib];
  25. [self.contentView addSubview:self.sdcycleScrollView];
  26. }
  27. #pragma mark - SDCycleScrollViewDelegate
  28. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
  29. }
  30. - (SDCycleScrollView *)sdcycleScrollView {
  31. if (!_sdcycleScrollView) {
  32. _sdcycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, (RQ_SCREEN_WIDTH - 32.f), (RQ_SCREEN_WIDTH - 32.f) * (95.f / 345.f)) imageNamesGroup:@[@"RQ-AD",@"banner0",@"banner1",@"banner2"]];
  33. _sdcycleScrollView.autoScrollTimeInterval = 5;
  34. _sdcycleScrollView.placeholderImage = RQImageNamed(@"未开发");
  35. _sdcycleScrollView.layer.cornerRadius = 10;
  36. _sdcycleScrollView.clipsToBounds = YES;
  37. _sdcycleScrollView.delegate = self;
  38. }
  39. return _sdcycleScrollView;
  40. }
  41. @end