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

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.

DGCollectionGridViewLayout Sample
DGCollectionGridViewLayout Sample

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Works with iOS 8+, tested on Xcode 8.2

Installing

To install the DGCollectionGridViewLayout using cocoapods

  • Add an entry in your Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'

target 'YourTarget' do
  frameworks
   use_frameworks!

  # Pods for YourTarget
  pod 'DGCollectionViewGridLayout'
end
  • Then install the dependency with the pod install command.

Usage

  • Initialize your layout by instantiate a DGCollectionViewGridLayout.
    let layout =  DGCollectionViewGridLayout()

Configuration

You can customize the component by enabling few options:

layout.lineSpacing = 10
layout.columnSpacing = 10
layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

Interacting with the component

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

self.collectionView.delegate = self
self.collectionView.dataSource = self
  • DGCollectionViewGridLayoutDelegate
    /**
    Gives the height of an item at an IndexPath. The highest item in the row will set the
    height of the row. Default is 100.
    **/
    @objc optional func collectionView(_ collectionView: UICollectionView,
                                              layout collectionViewLayout: DGCollectionViewGridLayout,
                                              heightForItemAt indexPath: IndexPath,
                                              columnWidth: CGFloat) -> CGFloat
    /**
    Gives the height of a ReusableView of Type Header. If no height is provided,
    no header will be displayed.
    **/
    @objc optional func collectionView(_ collectionView: UICollectionView,
                                              layout collectionViewLayout: DGCollectionViewGridLayout,
                                              heightForHeaderIn section: Int) -> CGFloat
    /**
    Gives the height of a ReusableView of Type Footer. If no height is provided,
    no footer will be displayed.
    **/
    @objc optional func collectionView(_ collectionView: UICollectionView,
                                              layout collectionViewLayout: DGCollectionViewGridLayout,
                                              heightForFooterIn section: Int) -> CGFloat
  • DGCollectionViewGridLayoutDataSource
    /**
    Gives the same width for each items depending on the value returned. Default is 1.
    **/
    @objc optional func numberOfColumns(in collectionView: UICollectionView) -> Int

Limitations

Current limitations are :

  • Performances issues when more than 3k items. (WIP)
  • Decoration View not handled
  • Scroll direction only vertical

Built With

Fastlane
Fastlane is a tool for iOS, Mac, and Android developers to automate tedious tasks like generating screenshots, dealing with provisioning profiles, and releasing your application.

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

DGCollectionGridViewLayout is licensed under the BSD 3-Clause license.

Latest podspec

{
    "name": "DGCollectionViewGridLayout",
    "version": "1.0.6",
    "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-swift",
    "authors": "Digipolitan",
    "source": {
        "git": "https://github.com/Digipolitan/collection-view-grid-layout-swift.git",
        "tag": "v1.0.6"
    },
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    },
    "source_files": "Sources/**/*.{swift,h}",
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This