Latest 2.0.0
Homepage https://github.com/Digipolitan/collection-view-grid-layout
License BSD
Platforms ios 8.0, tvos 9.0, requires ARC

Swift Version
Build Status
CocoaPods Compatible
Carthage Compatible
Platform
Twitter

Layout that allows you to display collection of data in grid without only very few lines of codes.
It can have the look of a UITableView or a UICollectionView.

CollectionGridViewLayout Sample
CollectionGridViewLayout Sample

Installation

CocoaPods

To install CollectionViewGridLayout with CocoaPods, add the following lines to your Podfile.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

pod 'CollectionViewGridLayout'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate CollectionViewGridLayout into your Xcode project using Carthage, specify it in your Cartfile:

github 'Digipolitan/collection-view-grid-layout ~> 2.0

Run carthage update to build the framework and drag the built CollectionViewGridLayout.framework into your Xcode project.

Usage

  • Initialize your layout by instantiate a CollectionViewVerticalGridLayout or CollectionViewHorizontalGridLayout.
    let layout =  CollectionViewVerticalGridLayout()

Interacting with the component

To Communicate with the layout, use the same way than UICollectionViewFlowLayout. Declare your component as CollectionViewDelegateVerticalGridLayout or CollectionViewDelegateHorizontalGridLayout, those inheriting respectively from UICollectionViewDelegate and UICollectionViewDataSource you just have to assign it to your collectionView.

self.collectionView.delegate = self
self.collectionView.dataSource = self
  • Common protocol for all grid layout direction
  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       rowSpacingForSection section: Int) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       columnSpacingForSection section: Int) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       insetForSection section: Int) -> UIEdgeInsets
  • CollectionViewDelegateVerticalGridLayout
  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       numberOfColumnsForSection section: Int) -> Int

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       weightForColumn column: Int,
                                       inSection section: Int) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       heightForItemAt indexPath: IndexPath,
                                       columnWidth: CGFloat) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       heightForHeaderInSection section: Int) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       heightForFooterInSection section: Int) -> CGFloat
  • CollectionViewDelegateHorizontalGridLayout
  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       numberOfRowsForSection section: Int) -> Int

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       weightForRow row: Int,
                                       inSection section: Int) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       widthForItemAt indexPath: IndexPath,
                                       rowHeight: CGFloat) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       widthForHeaderInSection section: Int) -> CGFloat

  @objc optional func collectionView(_ collectionView: UICollectionView,
                                       layout collectionViewLayout: UICollectionViewLayout,
                                       widthForFooterInSection section: Int) -> CGFloat

Contributing

See CONTRIBUTING.md for more details!

This project adheres to the Contributor Covenant Code of Conduct.
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [email protected].

License

CollectionViewGridLayout is licensed under the BSD 3-Clause license.

Latest podspec

{
    "name": "CollectionViewGridLayout",
    "version": "2.0.0",
    "summary": "Layout that allows you to display collection of data in grid with only very few lines of codes.",
    "homepage": "https://github.com/Digipolitan/collection-view-grid-layout",
    "authors": "Digipolitan",
    "source": {
        "git": "https://github.com/Digipolitan/collection-view-grid-layout.git",
        "tag": "v2.0.0"
    },
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    },
    "source_files": "Sources/**/*.{swift,h}",
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This