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
.
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 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.1
Run carthage update
to build the framework and drag the built CollectionViewGridLayout.framework
into your Xcode project.
- Initialize your layout by instantiate a
CollectionViewVerticalGridLayout
orCollectionViewHorizontalGridLayout
.
let layout = CollectionViewVerticalGridLayout()
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
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 contact@digipolitan.com.
CollectionViewGridLayout is licensed under the BSD 3-Clause license.