Latest 0.0.5
Homepage https://github.com/CoderJee/CJInfiniteLoopView
License MIT
Platforms ios 7.0, requires ARC
Dependencies Masonry
Frameworks UIKit
Authors

一款用起来so easy的左右无限滚动控件,一般用于首页banner

效果图

使用文档:自定义水平无限滚动控件之CJInfiniteLoopView

可使用cocoapods导入

    pod 'CJInfiniteLoopView'

基本使用

1.1.创建CJInfiniteLoopView

    CJInfiniteLoopView *infiniteLoopView = [[CJInfiniteLoopView alloc] initWithCustomPageControl:nil];
    infiniteLoopView.delegate = self;     // self需实现CJInfiniteLoopViewDelegate协议
    infiniteLoopView.dataSource = self;   // self需实现CJInfiniteLoopViewDataSource协议
    infiniteLoopView.pageIndicatorTintColor = [UIColor blueColor];
    infiniteLoopView.currentPageIndicatorTintColor = [UIColor redColor];
    infiniteLoopView.frame = CGRectMake(0, 0, self.view.width, 200);
    [self.view addSubview:infiniteLoopView];
    infiniteLoopView.timeInterval = 1.0;
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor blueColor];
    infiniteLoopView.placeHolderView = view;

2.设置CJInfiniteLoopView.h的数据源,实现CJInfiniteLoopViewDataSource协议,实现 – (NSInteger)numberOfItemsInLoopView:(CJInfiniteLoopView )loopView– (UIView )infiniteLoopView:(CJInfiniteLoopView )loopView viewForItemAtIndex:(NSInteger)index* 方法


- (NSInteger)numberOfItemsInLoopView:(CJInfiniteLoopView *)loopView
{
    return 3;
}

- (UIView *)infiniteLoopView:(CJInfiniteLoopView *)loopView viewForItemAtIndex:(NSInteger)index
{
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%ld",index + 1]]];
    return imageView;
}

3.如果要响应事件,则要实现CJInfiniteLoopViewDelegate协议,实现– (void)infiniteLoopView:(CJInfiniteLoopView )loopView didSelectItemAtIndex:(NSInteger)index* 方法

// 响应点击事件
- (void)infiniteLoopView:(CJInfiniteLoopView *)loopView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"%@", loopView);
}

如果不需要pageControl,则使用[[CJInfiniteLoopView alloc] init],使用initWithCustomPageControl方法创建如果传nil,则会有个默认的pageControl,也可以传自己自定义的pageControl

如有疑问,bug欢迎issue, 也可在微博上 @埃欧Ace 提疑问或者bug。如有bug欢迎各位指正,谢谢!

Latest podspec

{
    "name": "CJInfiniteLoopView",
    "version": "0.0.5",
    "summary": "u4e00u6b3eu7528u8d77u6765so easyu7684u5de6u53f3u65e0u9650u6edau52a8u63a7u4ef6uff0cu4e00u822cu7528u4e8eu9996u9875banner",
    "homepage": "https://github.com/CoderJee/CJInfiniteLoopView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "CoderJee": "[email protected]"
    },
    "social_media_url": "http://twitter.com/CoderJee",
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/CoderJee/CJInfiniteLoopView.git",
        "tag": "0.0.5"
    },
    "source_files": "InfiniteLoopScrollDemo/CJInfiniteLoopScrollView/**/*.{h,m}",
    "frameworks": "UIKit",
    "requires_arc": true,
    "dependencies": {
        "Masonry": []
    }
}

Pin It on Pinterest

Share This