《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRInviteBannerView.m 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // DRInviteBannerView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRInviteBannerView.h"
  9. #import "WLScrollView.h"
  10. @interface DRInviteBannerView ()<WLScrollViewDelegate>{
  11. WLScrollView *wlScrView;
  12. }
  13. @end
  14. @implementation DRInviteBannerView
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. self.layer.masksToBounds = YES;
  19. [self initSubViews];
  20. }
  21. return self;
  22. }
  23. - (void)initSubViews {
  24. wlScrView = [[WLScrollView alloc]initWithFrame:self.bounds];
  25. wlScrView.delegate = self;
  26. wlScrView.isAnimation = YES;
  27. //是否轮播。轮播设置为NO 或者不设置
  28. wlScrView.isEnableMargin = YES;
  29. wlScrView.scale = 0.7;
  30. wlScrView.marginX = 0;
  31. wlScrView.maxAnimationScale = 1;
  32. wlScrView.minAnimationScale = 0.8;
  33. wlScrView.backgroundColor = [UIColor clearColor];
  34. }
  35. #pragma mark - WLScrollViewDelegate
  36. - (NSInteger)numOfContentViewScrollView:(WLScrollView *)scrollView{
  37. return self.dataArr.count;
  38. }
  39. - (WLSubView *)scrollView:(WLScrollView *)scrollView subViewFrame:(CGRect)frame cellAtIndex:(NSInteger)index{
  40. WLSubView *view = [[WLSubView alloc] initWithFrame:frame Identifier:@"cellId"];
  41. view.backgroundColor = [UIColor yhGrayColor];
  42. view.tag = 1000+index;
  43. UIImageView *imgView=[[UIImageView alloc]initWithFrame:view.bounds];
  44. [imgView sd_setImageWithURL:[NSURL URLWithString:self.dataArr[index]]];
  45. [view addSubview:imgView];
  46. return view;
  47. }
  48. - (void)scrollView:(WLScrollView *)scrollView didSelectedAtIndex:(NSInteger)index{
  49. NSLog(@"点击 index %zd",index);
  50. }
  51. - (void)scrollView:(WLScrollView *)scrollView didCurrentCellAtIndex:(NSInteger)index{
  52. NSLog(@"现在显示的 index %zd",index);
  53. WLSubView *sub = [self scrollView:scrollView subViewFrame:[wlScrView getSubFrame] cellAtIndex:index];
  54. NSLog(@"%ld",(long)sub.tag);
  55. NSLog(@"%f",wlScrView.width);
  56. if (self.delegate &&[self.delegate respondsToSelector:@selector(didCurrentCellAtIndex:)]) {
  57. [self.delegate didCurrentCellAtIndex:index];
  58. }
  59. }
  60. -(void)setDataArr:(NSArray *)dataArr{
  61. _dataArr=dataArr;
  62. [wlScrView starRender];
  63. [self addSubview:wlScrView];
  64. }
  65. @end