加入代理<ImagePlayerViewDelegate>
初始化
_imageplayV = [[ImagePlayerView alloc]init];
_imageplayV.imagePlayerViewDelegate = self;
_imageplayV.hidePageControl = NO;
_imageplayV.endlessScroll = YES;
_imageplayV.pageControlPosition = ICPageControlPosition_BottomCenter;
_imageplayV.scrollInterval = 3.0f;
[topHeaderView addSubview:_imageplayV];
_imageplayV.pageControl.currentPageIndicatorTintColor = [UIColor redColor];
_imageplayV.pageControl.pageIndicatorTintColor = [UIColor whiteColor];
实现代理
#pragma mark - ImagePlayerViewDelegate
- (NSInteger)numberOfItems
{
return imageURLs.count;
}
- (void)imagePlayerView:(ImagePlayerView *)imagePlayerView loadImageForImageView:(UIImageView *)imageView index:(NSInteger)index
{
if (imageURLs.count>index) {
[imageView sd_setImageWithURL:[NSURL URLWithString:[imageURLs objectAtIndex:index]] placeholderImage:[UIImage imageNamed:@"banner_top"]];
}
}
- (void)imagePlayerView:(ImagePlayerView *)imagePlayerView didTapAtIndex:(NSInteger)index
{
NSLog(@"did tap index = %d", (int)index);
}
最后赋值刷新
imageURLs = @[@"http://sudasuta.com/wp-content/uploads/2013/10/10143181686_375e063f2c_z.jpg",
@"http://img01.taopic.com/150920/240455-1509200H31810.jpg",
@"http://img.taopic.com/uploads/allimg/110906/1382-110Z611025585.jpg"];
[_imageplayV reloadData];