【问题标题】:iCarousel Linear Infinite Effect?iCarousel 线性无限效应?
【发布时间】:2014-12-17 14:46:50
【问题描述】:

我想问一下如何创建一个具有线性无限效果的iCarousel? 我的意思是,它是直线型和旋转型的结合。 例如,数字 1-10 以线性方式显示,那么 10 旁边是 1。

这可能吗?谢谢

【问题讨论】:

    标签: objective-c ios8 icarousel


    【解决方案1】:

    首先,通过实现将轮播设置为换行

    - (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
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-03
      相关资源
      最近更新 更多