To run the example project, clone the repo, and run pod install from the Example directory first.
CCLoopScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CCLoopScrollView'CCLoopScrollView *loopScrollViewTop = [[CCLoopScrollView alloc] initWithFrame:CGRectMake(0, 110, self.view.frame.size.width, 100)];
loopScrollViewTop.delegate = self;
loopScrollViewTop.autoScrollDelay = 2.0;
[self.view addSubview:loopScrollViewTop];
[loopScrollViewTop reloadData];
#pragma mark - CCLoopScrollView Delegate
- (NSInteger)numberOfPageInLoopScrollView:(CCLoopScrollView *)loopScrollView {
//指定有多少个page
return 10;
}
- (UIView *)loopScrollView:(CCLoopScrollView *)loopScrollView viewForPageAtIndex:(NSInteger)index withPosition:(NSInteger)position {
//自定义每一个Page的视图
CCBannerView *pageView = (CCBannerView *)[loopScrollView dequeueReusableViewWithPosition:position];
if (!pageView) {
pageView = [[CCBannerView alloc] initWithFrame:loopScrollView.bounds];
}
[pageView setTitle:[NSString stringWithFormat:@"第 %ld 页",index + 1]];
if (index < _colors.count) {
[pageView setBackgroundColor:[_colors objectAtIndex:index]];
}
return pageView;
}
zhoushaoyou, zhouxbbbj1@126.com
CCLoopScrollView is available under the MIT license. See the LICENSE file for more info.
