Latest 0.0.3
Homepage https://github.com/zackschen/CCCycleView
License MIT
Platforms ios 9.0, requires ARC
Frameworks UIKit
Authors

一个view循环器,目前来说,可以用来制作:

轮播图 view循环 跑马灯效果
cycleImage cycleView cycleImage

Requirement

·Xcode8+

·iOS8+

·ARC

Installation

CocoaPods

  1. Add pod ‘CCCycleView’ to your Podfile.
  2. Run pod install or pod update.
  3. Import "CCViewScroolView.h"

Manually

  1. Download all the files in the CCCycleView subdirectory.
  2. Add the source files to your Xcode project.

使用

使用collectionView作为基础,需要在数据源对象中加入相应的reusekey,以根据数据不同,展示不同的view;还需要返回需要循环播放的view。

1、设置数据源reusekey及参数

NSMutableArray *data = [@[] mutableCopy];
for (int i = 0; i < 10; i++) {
    NSObject *model = [[NSObject alloc] init];
    model.cc_reUseStringKey = @"UIImageView";
    [data addObject:model];
}
self.viewScrollView.viewEdge = UIEdgeInsetsMake(5, 10, 2, 8);
self.viewScrollView.direction = UICollectionViewScrollDirectionHorizontal;
self.viewScrollView.timeInterval = 5.0f;
self.viewScrollView.infinite = YES;
self.viewScrollView.modelArray = data;//数据
self.viewScrollView.dataSource = self;
self.viewScrollView.delegate = self;
self.viewScrollView.userDragEnable = YES;
//回调来给每个view绑定数据
self.viewScrollView.configureViewBlock = ^(UIView *view, id model, NSInteger index) {
    UIImageView *imageView = (UIImageView *)view;
    imageView.image = [UIImage imageNamed:@"0"];
};
[self.viewScrollView layoutNeedUpdate];
[self.viewScrollView reloadData];

2、返回view

- (UIView *)cc_viewForModel:(NSObject *)model
{
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    imageView.clipsToBounds = YES;
    return imageView;
}

当然还有其他参数可以设置

/**
 default is UICollectionViewScrollDirectionHorizontal
 warning:after U change,u should call layoutNeedUpdate
 */
@property (assign, nonatomic) UICollectionViewScrollDirection direction;
/**
 whether user can drag the view
 default is YES
 */
@property (assign, nonatomic,getter=isUserDragEnable) BOOL userDragEnable;
/**
 whether the scroll is infinite
 default is YES
 */
@property (assign, nonatomic,getter=isInfinite) BOOL infinite;
/**
 whether the scroll is pageControl
 default is YES
 */
@property (assign, nonatomic,getter=isPageControl) BOOL pageControl;
/**
 the auto scroll time
 default is 3.0f
 */
@property (assign, nonatomic) NSTimeInterval timeInterval;
/**
 the item padding
 When scrollDirection is horizontal,item padding is right to next's left.
 When scrollDirection is vertical,item padding is bottom to next's top.
 default is 10.0
 warning:after U change,u should call layoutNeedUpdate
 */
@property (assign, nonatomic) CGFloat itemPadding;
/**
 the edge in cell.contentView
 default is UIEdgeInsetsZero
 warning:after U change,u should call layoutNeedUpdate
 */
@property (assign, nonatomic) UIEdgeInsets viewEdge;
/**
 the view Size
 default is (view's height and view's width) * 0.8
 warning:after U change,u should call layoutNeedUpdate
 */
@property (assign, nonatomic) CGSize itemSize;
/**
 the dataSource
 */
@property (strong, nonatomic) NSArray* modelArray;

目前的回调仅暴露了2个方法(如果后期有需要,可以加上)

@protocol CCViewScrollViewDelegate <NSObject>

- (void)cc_scrollDidSelectItem:(NSInteger)index model:(id)model view:(UIView *)view;

- (void)cc_scrollDidScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex;

@end

License

CCCycleView is released under the MIT license.

Feedback

·Email:[email protected]

·Weibo:鐵甲陳小寶

·Twitter:zacks_Chen

Latest podspec

{
    "name": "CCCycleView",
    "version": "0.0.3",
    "summary": "An easy reuse cycle view",
    "description": "u76eeu524du53efu4ee5u7528u6765u8f6eu64adu56feu3001u8dd1u9a6cu706fu3001u5faau73afviewu7684u7b80u5355u6613u7528u63a7u4ef6",
    "homepage": "https://github.com/zackschen/CCCycleView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "zacks": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/zackschen/CCCycleView.git",
        "tag": "0.0.3"
    },
    "source_files": [
        "CCCycleView",
        "CCCycleView/*.{h,m}"
    ],
    "public_header_files": "CCCycleView/*.h",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This