要实现该功能主要就是解决以下几个问题:
1.collection的自动滚动。
2.图片滚动到开头和末尾是回到另一端重新开始的无缝连接。
其中第一个问题用定时器就能解决
self.timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(scrollImage) userInfo:nil repeats:YES];
#pragma mark - 定时器滚动collectionView
-(void)scrollImage{
int page = (int)_collection.contentOffset.x / self.view.frame.size.width;
page++;
if (page < 6)
{
[_collection setContentOffset:CGPointMake(page * self.view.frame.size.width, 0) animated:YES];
}
}