1
votes

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.

1

1 Answers

1
votes

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