[Solved] i want create a CollectionView for images with auto scrolling like loop


Use this code. I hope this helps you.

Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(moveToNextPage), userInfo: nil, repeats: true)

@objc func moveToNextPage (){
        if self.x < dataArray.count {
            let indexPath = IndexPath(item: x, section: 0)
            sliderPageCont.currentPage=x
            sliderColletion.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
            self.x = self.x + 1
        } else {
            self.x = 0

        }
    }

solved i want create a CollectionView for images with auto scrolling like loop