Latest 0.0.4
Homepage https://github.com/ingocraft/LMCenteredCollectionView
License MIT
Platforms ios 10.0
Authors

Swift Version
Cocoapods
GitHub
Cocoapods platforms

Introduction

LMCenteredCollectionView is a infinite scroll view.

Example

LMCenteredCollectionView LMCenteredCollectionView

Usage

Create your cell,

class YourCell: LMCenteredCollectionViewCell {}

Then show centeredCollectionView in YourViewController,

class YourViewController: UIViewController {
    private var centeredCollectionView: LMCenteredCollectionView!

    override func viewDidLoad() {
        centeredCollectionView = LMCenteredCollectionView(frame: UIScreen.main.bounds, direction: .horizontal)
        centeredCollectionView.register(YourCell.self)
        view.addSubview(centeredCollectionView)
    }
}

You must implement dataSource to show your contents,

centeredCollectionView.dataSource = self

extension YourViewController: LMCenteredCollectionViewDataSource {
    func numberOfItems(in centeredCollectionView: LMCenteredCollectionView) -> Int {
        return 10
    }

    func centeredCollectionView(_ centeredCollectionView: LMCenteredCollectionView, cellForItemAt index: Int) -> LMCenteredCollectionViewCell {
        let cell = centeredCollectionView.dequeueReusableCell(for: index) as! YourCell
        return cell
    }
}

Implementing delegate if you want to resize items and spacing between items. The default size is (50, 50) and the interitemSpacing is 10.

For more control you can see LMCenteredCollectionViewDelegate for detail.

centeredCollectionView.delegate = self

extension YourViewController: LMCenteredCollectionViewDelegate {
    func sizeOfItems(in centeredCollectionView: LMCenteredCollectionView) -> CGSize {
        return CGSize(width: 50, height: 50)
    }

    func interitemSpacingBetweenItems(in centeredCollectionView: LMCenteredCollectionView) -> CGFloat {
        return 10
    }
}

Installation

CocoaPods

Add LMCenteredCollectionView in your Podfile.

pod 'LMCenteredCollectionView'

Then,

pod install

Manual

Copy Sources folder to your project. That’s it.

Licence

The MIT License (MIT)

Latest podspec

{
    "name": "LMCenteredCollectionView",
    "version": "0.0.4",
    "summary": "infinite, centered, collection view.",
    "homepage": "https://github.com/ingocraft/LMCenteredCollectionView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Liam": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_versions": [
        "4.0",
        "4.2",
        "5.0"
    ],
    "source": {
        "git": "https://github.com/ingocraft/LMCenteredCollectionView.git",
        "tag": "0.0.4"
    },
    "source_files": [
        "Sources/**/*.swift",
        "Sources/LMCenteredCollectionView.h"
    ],
    "public_header_files": "Sources/LMCenteredCollectionView.h",
    "swift_version": "5.0"
}

Pin It on Pinterest

Share This