只要几行代码,快速集成轮播控件,支持本地图片和网络图片,支持点击事件,可定制播放速度、指示器颜色/位置、默认图等。
pod 'JXScrollView'
两步快速集成方法:
JXScrollViewConfig *config = [JXScrollViewConfig defalutConfig];
JXScrollView *scroll = [[JXScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREENW, 200) config:config dataSource:self delegate:self];
[self.view addSubview:scroll];
[scroll start];
//返回轮播图片数量
-(NSInteger)numberOfItemInScrollView:(JXScrollView *)scrollView{
return imageArr.count;
}
//返回轮播的图片url
-(NSURL*)scrollView:(JXScrollView *)scrollView urlForItemAtIndex:(NSInteger)index{
return [NSURL URLWithString:imageArr[index]];
}
效果:
如果要修改PageControl在左边,选中颜色为红色,未选中为绿色。将初始化改为:
JXScrollViewConfig *config = [JXScrollViewConfig defalutConfig];
config.pageControlPosition(JXScrollViewPageControlPositionLeft).pageControlTintColor([UIColor redColor]).pageIndicatorSelectedTintColor([UIColor greenColor]);
JXScrollView *scroll = [[JXScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREENW, 200) config:config dataSource:self delegate:self];
[self.view addSubview:scroll];
[scroll start];