Latest 0.4.1
License MIT
Platforms ios 8.0, tvos 9.0
Dependencies CocoaProxy

CI Status


To run the example project, clone the repo, and run pod install from the Example directory first.



InfiniteLayout is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'InfiniteLayout'


@IBOutlet weak var collectionView: InfiniteCollectionView!

InfiniteCollectionView doesn’t need any other delegate or dataSource,
just use UICollectionViewDataSource and UICollectionViewDelegate in the same way as you’ll use it in any other UICollectionView.

InfiniteLayout provides 3 classes for infinite scrolling:

InfiniteLayout: an UICollectionViewFlowLayout

InfiniteCollectionView: an UICollectionView with InfiniteLayout

InfiniteCollectionViewController: an UICollectionViewController with InfiniteCollectionView


InfiniteCollectionView may create fake indexPath,

To get the real indexPath call

func indexPath(from infiniteIndexPath: IndexPath) -> IndexPath

To get the real section call

func section(from infiniteSection: Int) -> Int


InfiniteCollectionView provide a paging functionality, you can enable it by setting the isItemPagingEnabled flag to true

self.infiniteCollectionView.isItemPagingEnabled = true

When the isItemPagingEnabled flag is enabled you can adjust the deceleration rate by setting the velocityMultiplier, the more the value is high, the more the deceleration is long

self.infiniteCollectionView.velocityMultiplier = 1 // like scrollView with paging (default value)
self.infiniteCollectionView.velocityMultiplier = 500 // like scrollView without paging

When the isItemPagingEnabled flag is enabled you can set a preferredCenteredIndexPath, this value is used to calculate the preferred visible cell to center each time the collectionView will change its contentSize

self.infiniteCollectionView.preferredCenteredIndexPath = [0, 0] // center the cell at [0, 0] if visible (default value)
self.infiniteCollectionView.preferredCenteredIndexPath = nil // center the closest cell from center


InfiniteCollectionView provide an infiniteDelegate protocol used to get the centered IndexPath, usefull if you want to use an InfiniteCollectionView like a Picker.

func infiniteCollectionView(_ infiniteCollectionView: InfiniteCollectionView, didChangeCenteredIndexPath centeredIndexPath: IndexPath?)


InfiniteCollectionView provide a subspec InfiniteLayout/Rx

pod 'InfiniteLayout/Rx'

To use InfiniteCollectionView with RxSwift without conflicts between NSProxy

Use RxInfiniteCollectionView instead of InfiniteCollectionView

@IBOutlet weak var collectionView: RxInfiniteCollectionView!

RxInfiniteCollectionView provides 2 dataSources for SectionModel:

RxInfiniteCollectionViewSectionedReloadDataSource and RxInfiniteCollectionViewSectionedAnimatedDataSource


Without sections:

// automatic cell dequeue
    .bind(to: infiniteCollectionView.rx.items(cellIdentifier: "cell", cellType: Cell.self, infinite: true)) { row, element, cell in
        cell.update(index: row) // update your cell
    }.disposed(by: disposeBag)

// custom cell dequeue
    .bind(to: infiniteCollectionView.rx.items(infinite: true)) { collectionView, row, element in
        let indexPath = IndexPath(row: row, section: 0)
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! Cell // dequeue your cell
        cell.update(index: row) // update your cell
        return cell
    }.disposed(by: disposeBag)

With sections:

let dataSource = RxInfiniteCollectionViewSectionedReloadDataSource<SectionModel<Int, Int>>(configureCell: { dataSource, collectionView, indexPath, element in
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! Cell // dequeue your cell
    cell.update(index: indexPath.row) // update your cell
    return cell

                    SectionModel(model: 0, items: Array(0..<2)),
                    SectionModel(model: 1, items: Array(0..<10))
    .bind(to: infiniteCollectionView.rx.items(dataSource: dataSource))
    .disposed(by: disposeBag)

for animations just use RxInfiniteCollectionViewSectionedAnimatedDataSource & AnimatableSectionModel

Centered IndexPath:

RxInfiniteCollectionView provide Reactive extension for itemCentered & modelCentered

    .drive(onNext: { [unowned self] indexPath in
        self.selectedView.update(index: indexPath.row) // update interface with indexPath
    }).disposed(by: disposeBag)

    .drive(onNext: { [unowned self] element in
        self.selectedView.update(index: element) // update interface with model
    }).disposed(by: disposeBag)


Arnaud Dorgans, [email protected]


InfiniteLayout is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "InfiniteLayout",
    "version": "0.4.1",
    "summary": "Horizontal and Vertical infinite scrolling feature for UICollectionView with Paging, NSProxy delegate, Reactive extension",
    "description": "Horizontal and Vertical infinite scrolling feature for UICollectionView with Paging, NSProxy delegate, Reactive extension, SectionModel & AnimatableSectionModel support",
    "homepage": "",
    "screenshots": [
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Arnaud Dorgans": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.4.1"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    "dependencies": {
        "CocoaProxy": [
            "~> 0"
    "default_subspecs": "Core",
    "subspecs": [
            "name": "Core",
            "source_files": "InfiniteLayout/Classes/**/*"
            "name": "Rx",
            "dependencies": {
                "InfiniteLayout/Core": [
                    "~> 0"
                "RxSwift": [
                    "~> 5"
                "RxCocoa": [
                    "~> 5"
                "RxDataSources": [
                    "~> 4"
            "source_files": "InfiniteLayout/Rx/**/*"

Pin It on Pinterest

Share This