https://github.com/digipolitan/collection-view-grid-layout
https://github.com/digipolitan/collection-view-grid-layout
carthage cocoapods collection-view fastlane framework ios swift tvos
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/digipolitan/collection-view-grid-layout
- Owner: Digipolitan
- License: bsd-3-clause
- Created: 2017-01-05T17:06:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-08T10:24:56.000Z (about 6 years ago)
- Last Synced: 2024-03-14T23:47:43.504Z (about 1 year ago)
- Topics: carthage, cocoapods, collection-view, fastlane, framework, ios, swift, tvos
- Language: Swift
- Size: 1.21 MB
- Stars: 24
- Watchers: 7
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
CollectionViewGridLayout
=================================[](https://developer.apple.com/swift/)
[](https://travis-ci.org/Digipolitan/collection-view-grid-layout)
[](https://img.shields.io/cocoapods/v/CollectionViewGridLayout.svg)
[](https://github.com/Carthage/Carthage)
[](http://cocoadocs.org/docsets/CollectionViewGridLayout)
[](http://twitter.com/Digipolitan)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`.
## Installation
### CocoaPods
To install CollectionViewGridLayout with CocoaPods, add the following lines to your `Podfile`.
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!pod 'CollectionViewGridLayout'
```### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ 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.
## Usage
- Initialize your layout by instantiate a `CollectionViewVerticalGridLayout` or `CollectionViewHorizontalGridLayout`.
```swift
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`.
```swift
self.collectionView.delegate = self
self.collectionView.dataSource = self
```- Common protocol for all grid layout direction
```swift
@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
```swift
@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
```swift
@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](CONTRIBUTING.md) for more details!
This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [[email protected]](mailto:[email protected]).## License
CollectionViewGridLayout is licensed under the [BSD 3-Clause license](LICENSE).