iosswifticarousel

Is there a way to pause the images in iCarousel for iOS?


I am currently using iCarousel for the project and I have been asked to pause every image on the front for N seconds and then keep scrolling (there is autoscroll method). I tried using double timer, tried to change the images, but no success.


Solution

  • This is what I came up with:

    var activeItemIndex = 0
    Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { timer in
        activeItemIndex += 1
        if activeItemIndex == carousel.numberOfItems {
            activeItemIndex = 0
        }
        carousel.scrollToItem(at: activeItemIndex, duration: 3)
    }