Latest0.1.1
Homepagehttps://github.com/rafaelsrocha/ExcelCollectionViewLayout
LicenseMIT
Platformsios 8.0
FrameworksUIKit

Version
License
Platform
Language

Based on Brightec’s solution this pod will allow you to have an UIColletionView working like an Excel (PC) or Numbers’ (OS X) sheet. Plus, and not less important, you will have the total control about your UICollectionView’s design and how it should look like!

This is the expected behavior in the implemented UICollectionView:

UICollectionView's expected behavior

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 4.0

Installation

CocoaPods

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

pod 'ExcelCollectionViewLayout'

Manually

Just drag and drop ExcelCollectionViewLayout.swift inside your project.

Usage

Set ExcelCollectionViewLayout as your UICollectionView’s layout:

  • Go to your UICollectionView’s inspector
  • Select Custom in the Layout selector
  • Type ExcelCollectionViewLayout in the Class selector (it should autocomplete and/or appear in the dropdown list).

UICollectionView's inspector

Set ExcelCollectionViewLayout’s delegate, responsible for calculating each column’s items’ size:

override func viewDidLoad() {
    super.viewDidLoad()

    if let collectionLayout = collectionView.collectionViewLayout as? ExcelCollectionViewLayout {
        collectionLayout.delegate = self
    }
}

After setting ExcelCollectionViewLayoutDelegate, you must implement the delegate’s method which will allow you to calculate column’s items’ size or just set it arbitrarily:

func collectionViewLayout(_ collectionViewLayout: ExcelCollectionViewLayout, sizeForItemAtColumn columnIndex: Int) -> CGSize {
    return CGSize(width: 100, height: 50)
}

PS.: This pod’s example has a good example of calculated items’ size.

And we are all set up! As said before, you still have the total control about your UICollectionView’s design and how it should be like, all it takes care of is the UICollectionView’s cells arrangement!

Keep in mind: when setting UICollectionViewDataSource’s methods the sections are the rows and rows are the columns.

Section-row relationship.

Example

To run the example project simply type pod try ExcelCollectionViewLayout on Terminal. Or clone the repo, and run pod install from the Example directory first.

Author

Created, updated and maintained by Rafael Rocha.

License

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

Latest podspec

{
    "name": "ExcelCollectionViewLayout",
    "version": "0.1.1",
    "summary": "An Excel-like UICollectionView's layout.",
    "description": "This will allow you to work with UICollectionViews like Excel and Number's sheets.",
    "homepage": "https://github.com/rafaelsrocha/ExcelCollectionViewLayout",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "Rafael Rocha",
    "source": {
        "git": "https://github.com/rafaelsrocha/ExcelCollectionViewLayout.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ExcelCollectionViewLayout/Classes/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This