Latest 1.0.0
Homepage https://github.com/whde/Loop
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation, CoreGraphics, UIKit
Authors

Loop

无限滚动视图, 适用于Banner的滚动

使用说明:

  • 1.下载项目,打开项目
  • 2.command+B打包Loop.Framework
  • 3.将Loop.Framework导入到自己的项目中

  • 4.导入头文件

    #import <Loop/CLoopScrollView.h>
    #import <Loop/CLoopCell.h>
  • 5.创建一个继承于CLoopCell的Cell
  • 6.实现CLoopCell中的两个方法
    例如简单的Banner:

    
    #import "CBannerLoopCell.h"
    #import "CTopModel.h"
    @interface CBannerLoopCell() {
    UIImageView *imgView;
    }
    @end

@implementation CBannerLoopCell

  • (id)initWith:(id)model withScrollViewFrame:(CGRect)rect{
    self = [super initWith:model withScrollViewFrame:rect];
    imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0,
    0,
    rect.size.width,
    rect.size.height)];
    imgView.contentMode = UIViewContentModeScaleAspectFill;
    imgView.clipsToBounds = YES;
    [self addSubview:imgView];
    [self reloadWith:model];
    return self;
    }

  • (void)reloadWith:(id)model{
    [super reloadWith:model];
    NSURL url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", ((CTopModel )model).imageUrl]];
    [imgView setImageWithURL:url placeholderImage:nil];
    }

@end

- 7.创建LoopScrollView并addSubView
```objective-c
_topView = [[CLoopScrollView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth*0.5)
                                  scrollDirection:LoopScrollViewScrollDirectionLandscape 
                                           models:_mainModel.topArray
                                      ofCellClass:[CBannerLoopCell class]];
[_topView setRollingDelayTime:4.0];
[_topView setSquare:0];
[header addSubview:_topView];
__block UILabel *weekTopPage = _topPage;
[_topView setScrollBlock:^(CLoopScrollView *loopScrollView, NSInteger index, id model) {
    NSLog(@"%d/%lu", (int)index+1, (unsigned long)[loopScrollView.models count]);
}];
__block CViewController *weekSelf = self;
[_topView setSelectBlock:^(CLoopScrollView *loopScrollView, CLoopCell *view, NSInteger index, id model) {
    [weekSelf doSomething]
}];

Latest podspec

{
    "name": "WhdeLoop",
    "version": "1.0.0",
    "summary": "iOS Banner.",
    "homepage": "https://github.com/whde/Loop",
    "license": "MIT",
    "authors": {
        "Whde": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/whde/Loop.git",
        "tag": "1.0.0"
    },
    "source_files": "WhdeLoop/Class/*{h,m}",
    "frameworks": [
        "Foundation",
        "CoreGraphics",
        "UIKit"
    ],
    "requires_arc": true,
    "description": "iOS Banner u65e0u9650u6edau52a8"
}

Pin It on Pinterest

Share This