123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- //
- // KBInviteBannerView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/19.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBInviteBannerView.h"
- #import "WLScrollView.h"
- @interface KBInviteBannerView ()<WLScrollViewDelegate>{
- WLScrollView *wlScrView;
- }
- @end
- @implementation KBInviteBannerView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.layer.masksToBounds = YES;
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
-
- wlScrView = [[WLScrollView alloc]initWithFrame:self.bounds];
- wlScrView.delegate = self;
- wlScrView.isAnimation = YES;
-
- //是否轮播。轮播设置为NO 或者不设置
- wlScrView.isEnableMargin = YES;
- wlScrView.scale = 0.7;
- wlScrView.marginX = 0;
- wlScrView.maxAnimationScale = 1;
- wlScrView.minAnimationScale = 0.8;
- wlScrView.backgroundColor = [UIColor clearColor];
- }
- #pragma mark - WLScrollViewDelegate
- - (NSInteger)numOfContentViewScrollView:(WLScrollView *)scrollView{
- return self.dataArr.count;
- }
- - (WLSubView *)scrollView:(WLScrollView *)scrollView subViewFrame:(CGRect)frame cellAtIndex:(NSInteger)index{
- WLSubView *view = [[WLSubView alloc] initWithFrame:frame Identifier:@"cellId"];
- view.backgroundColor = [UIColor yhGrayColor];
- view.tag = 1000+index;
- UIImageView *imgView=[[UIImageView alloc]initWithFrame:view.bounds];
- [imgView sd_setImageWithURL:[NSURL URLWithString:self.dataArr[index]]];
- [view addSubview:imgView];
- return view;
- }
- - (void)scrollView:(WLScrollView *)scrollView didSelectedAtIndex:(NSInteger)index{
- NSLog(@"点击 index %zd",index);
- }
- - (void)scrollView:(WLScrollView *)scrollView didCurrentCellAtIndex:(NSInteger)index{
- NSLog(@"现在显示的 index %zd",index);
- WLSubView *sub = [self scrollView:scrollView subViewFrame:[wlScrView getSubFrame] cellAtIndex:index];
- NSLog(@"%ld",(long)sub.tag);
- NSLog(@"%f",wlScrView.width);
- if (self.delegate &&[self.delegate respondsToSelector:@selector(didCurrentCellAtIndex:)]) {
- [self.delegate didCurrentCellAtIndex:index];
- }
-
- }
- -(void)setDataArr:(NSArray *)dataArr{
- _dataArr=dataArr;
- [wlScrView starRender];
- [self addSubview:wlScrView];
- }
- @end
|