BadhanGanesh / BJAutoScrollingCollectionView

A very simple UICollectionView subclass which auto scrolls cells with a single method call.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BJAutoScrollingCollectionView

A very simple UICollectionView subclass which auto scrolls cells with single line of code

Auto Scroll Demo

Usage

  • Drag and Drop the BJAutoScrollingCollectionView.swift file (Located inside the Source folder) into your Xcode project.

  • Make your collection view an instance of BJAutoScrollingCollectionView

@IBOutlet weak var collectionView: BJAutoScrollingCollectionView!
  • Set the desired scrollInterval property. (Default is 3 seconds)
self.collectionView.scrollInterval = 2
  • Whenever you are ready, call startScrolling method to start the auto-scrolling:
@IBAction func startScrollingButtonTapped(_ sender: Any) {
    self.collectionView.startScrolling()
}
  • You can also scroll to previous or next cell by calling scrollToPreviousOrNextCell method by supplying a direction parameter (Left or Right):
@IBAction func nextButtonTapped(_ sender: Any) {
    self.collectionView.scrollToPreviousOrNextCell(direction: .right)
}

License

This code is distributed under the terms and conditions of the MIT license.

About

A very simple UICollectionView subclass which auto scrolls cells with a single method call.

License:MIT License


Languages

Language:Swift 100.0%