使用CocoaPods。
在您的Podfile中
pod 'SCLoopScrollView'
获取SCNumberKeyBoard
#import "SCLoopScrollView.h"
将SCLoopScrollViewDemo/Classes
文件夹拖入您的项目中
#import "SCLoopScrollView.h"
NSArray *images = @[@"http://i8.tietuku.com/a6542887e864efc0.jpg",
[UIImage imageNamed:@"3"],
@"http://i8.tietuku.com/5730f7ebadae2c41.jpg",
[UIImage imageNamed:@"4"],
@"http://i8.tietuku.com/149caebe062fc98c.jpg"];
SCLoopScrollView *scrollView = [[SCLoopScrollView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.width*0.75)];
scrollView.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:scrollView];
scrollView.dataSource = images;
[scrollView show:^(NSInteger index) {
NSLog(@"Tap Index:%@", @(index));
} scrolled:^(NSInteger index) {
NSLog(@"Current Index:%@", @(index));
}];
NSArray *images = @[@"http://i8.tietuku.com/a6542887e864efc0.jpg",
[UIImage imageNamed:@"3"],
@"http://i8.tietuku.com/5730f7ebadae2c41.jpg",
[UIImage imageNamed:@"4"],
@"http://i8.tietuku.com/149caebe062fc98c.jpg"];
_scrollView.dataSource = images;
__weak __typeof__(self)weakSelf = self;
[_scrollView show:^(NSInteger index) {
__strong __typeof__(self)strongSelf = weakSelf;
strongSelf.tapLabel.text = @(index).stringValue;
} scrolled:^(NSInteger index) {
__strong __typeof__(self)strongSelf = weakSelf;
strongSelf.indexLabel.text = @(index).stringValue;
}];
pod 'SCLoopScrollView'
SCLoopScrollViewDemo/Classes
文件夹中的所有文件拖入项目中#import "SCLoopScrollView.h"
NSArray *images = @[@"http://i8.tietuku.com/a6542887e864efc0.jpg",
[UIImage imageNamed:@"3"],
@"http://i8.tietuku.com/5730f7ebadae2c41.jpg",
[UIImage imageNamed:@"4"],
@"http://i8.tietuku.com/149caebe062fc98c.jpg"];
SCLoopScrollView *scrollView = [[SCLoopScrollView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.width*0.75)];
scrollView.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:scrollView];
scrollView.dataSource = images;
[scrollView show:^(NSInteger index) {
NSLog(@"Tap Index:%@", @(index));
} scrolled:^(NSInteger index) {
NSLog(@"Current Index:%@", @(index));
}];
NSArray *images = @[@"http://i8.tietuku.com/a6542887e864efc0.jpg",
[UIImage imageNamed:@"3"],
@"http://i8.tietuku.com/5730f7ebadae2c41.jpg",
[UIImage imageNamed:@"4"],
@"http://i8.tietuku.com/149caebe062fc98c.jpg"];
_scrollView.dataSource = images;
__weak __typeof__(self)weakSelf = self;
[_scrollView show:^(NSInteger index) {
__strong __typeof__(self)strongSelf = weakSelf;
strongSelf.tapLabel.text = @(index).stringValue;
} scrolled:^(NSInteger index) {
__strong __typeof__(self)strongSelf = weakSelf;
strongSelf.indexLabel.text = @(index).stringValue;
}];