iCarousel线性无限效果?

时间:2014-12-17 14:46:51

标签: objective-c ios8 icarousel

我想问一下如何创建一个具有线性无限效果的iCarousel? 我的意思是,它是线性和旋转型的组合。 例如,数字1-10以线性方式显示,然后紧接着10是1.

这可能吗?感谢

1 个答案:

答案 0 :(得分:0)

首先,通过实施

将您的轮播设置为包装
- (BOOL)carouselShouldWrap:(iCarousel *)carousel {
//wrap all carousels
return YES;
}

接下来,您可以使用NSTimer来启动滚动。例如:

self.scrollTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(scrollCarousel) userInfo:nil repeats:YES];

- (void)scrollCarousel {
 NSInteger newIndex=self.carousel.currentItemIndex++;
 if (newIndex > self.carousel.numberOfItems) {
   newIndex=0;
 }

 [self.carousel scrollToItemAtIndex:newIndex duration:5]; // takes 5 seconds to scroll

}