酷店

KDPBannerCell.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // KDPBannerCell.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/4.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPBannerCell.h"
  9. @implementation KDPBannerCell
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. [self addSubview:self.sdCycleView];
  15. [self.sdCycleView mas_makeConstraints:^(MASConstraintMaker *make) {
  16. make.top.mas_equalTo(13);
  17. make.left.mas_equalTo(10);
  18. make.bottom.mas_equalTo(-10);
  19. make.right.mas_equalTo(-10);
  20. }];
  21. }
  22. return self;
  23. }
  24. -(SDCycleScrollView *)sdCycleView
  25. {
  26. if (!_sdCycleView) {
  27. _sdCycleView =[[SDCycleScrollView alloc]init];
  28. _sdCycleView.backgroundColor=[UIColor colorWithHexString:LineColor];
  29. _sdCycleView.delegate=self;
  30. }
  31. return _sdCycleView;
  32. }
  33. -(void)setBannerArr:(NSArray *)bannerArr
  34. {
  35. _bannerArr = bannerArr;
  36. NSMutableArray *array =[NSMutableArray array];
  37. for (KDPBannerModel *model in bannerArr) {
  38. [array addObject:model.img];
  39. }
  40. self.sdCycleView.imageURLStringsGroup=array;
  41. }
  42. -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
  43. {
  44. if (self.bannerBlock) {
  45. self.bannerBlock(self.bannerArr[index]);
  46. }
  47. }
  48. @end