Skip to content

一个轻量级的循环滑动组件,只用3个Page实现循环滚动,可自定义滚动动画的时间和效果

License

Notifications You must be signed in to change notification settings

syzhou1223/CCLoopScrollView

Repository files navigation

CCLoopScrollView

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

CCLoopScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'CCLoopScrollView'

运行效果

img

使用示例

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;
}

Author

zhoushaoyou, zhouxbbbj1@126.com

License

CCLoopScrollView is available under the MIT license. See the LICENSE file for more info.

About

一个轻量级的循环滑动组件,只用3个Page实现循环滚动,可自定义滚动动画的时间和效果

Resources

License

Stars

Watchers

Forks

Packages

No packages published