支持pod : pod 'YLLoopScrollView'
#import "YLLoopScrollView.h"
// 传入轮播的时间(0 代表不启用定时器),需要轮播的自定义view,和需要重新赋值的model
YLLoopScrollView *scrollView = [YLLoopScrollView loopScrollViewWithTimer:2 customView:^NSDictionary *{
return @{@"YLCustomView" : @"model"};
}];
scrollView.clickedBlock = ^(YLLoopScrollView *loopScrollView, NSInteger index) {
// 点击回调
NSLog(@"index : %d", index);
};
scrollView.didScrollBlock = ^(YLLoopScrollView *loopScrollView, UIScrollView *scrollView) {
// 滚动过程中回调
};
scrollView.willEndScrollBlock = ^(YLLoopScrollView *loopScrollView, UIScrollView *scrollView) {
// 滚动结束,将要更新数据时回调
};
scrollView.didEndScrollBlock = ^(YLLoopScrollView *loopScrollView, UIScrollView *scrollView) {
// 滚动结束回调
};
// arr里存放的是自定义view的model
scrollView.dataSourceArr = arr;
scrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, 150);
[self.view addSubview:scrollView];
NSArray *arr = @[[UIImage imageNamed:@"1.jpg"],
[UIImage imageNamed:@"2.jpg"],
[UIImage imageNamed:@"3.jpg"],
[UIImage imageNamed:@"4.jpg"]];
YLLoopScrollView *scrollView = [YLLoopScrollView loopScrollViewWithTimer:2 customView:^NSDictionary *{
return @{@"UIImageView" : @"image"};
}];
scrollView.dataSourceArr = arr;
scrollView.clickedBlock = ^(YLLoopScrollView *loopScrollView, NSInteger index) {
// todo
};
scrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, 100);
[self.view addSubview:scrollView];