TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | BSD |
ReleasedLast Release | Feb 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✓ |
Maintained by Benoit BRIATTE.
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
.
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.
Works with iOS 8+, tested on Xcode 8.2
To install the DGCollectionGridViewLayout using cocoapods
# 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
pod install
command. let layout = DGCollectionViewGridLayout()
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)
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
/**
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
/**
Gives the same width for each items depending on the value returned. Default is 1.
**/
@objc optional func numberOfColumns(in collectionView: UICollectionView) -> Int
Current limitations are :
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.
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.
DGCollectionGridViewLayout is licensed under the BSD 3-Clause license.