Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmedalmasri/sncollectionviewlayout
Collection View Layouts is a set of custom flow layouts for iOS which imitate general data grid approaches for mobile apps.
https://github.com/ahmedalmasri/sncollectionviewlayout
collectionview collectionviewlayout grid-layout ios ios-swift swift swift-library swift4 uicollectionview uicollectionviewflowlayout xcode
Last synced: about 3 hours ago
JSON representation
Collection View Layouts is a set of custom flow layouts for iOS which imitate general data grid approaches for mobile apps.
- Host: GitHub
- URL: https://github.com/ahmedalmasri/sncollectionviewlayout
- Owner: ahmedAlmasri
- License: mit
- Created: 2018-12-01T10:06:31.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T23:27:46.000Z (over 3 years ago)
- Last Synced: 2024-10-28T21:52:51.102Z (19 days ago)
- Topics: collectionview, collectionviewlayout, grid-layout, ios, ios-swift, swift, swift-library, swift4, uicollectionview, uicollectionviewflowlayout, xcode
- Language: Swift
- Homepage:
- Size: 176 KB
- Stars: 107
- Watchers: 8
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SNCollectionViewLayout
[![CI Status](https://img.shields.io/travis/ahmedAlmasri/SNCollectionViewLayout.svg?style=flat)](https://travis-ci.org/ahmedAlmasri/SNCollectionViewLayout)
[![Version](https://img.shields.io/cocoapods/v/SNCollectionViewLayout.svg?style=flat)](https://cocoapods.org/pods/SNCollectionViewLayout)
[![License](https://img.shields.io/cocoapods/l/SNCollectionViewLayout.svg?style=flat)](https://cocoapods.org/pods/SNCollectionViewLayout)
[![Platform](https://img.shields.io/cocoapods/p/SNCollectionViewLayout.svg?style=flat)](https://cocoapods.org/pods/SNCollectionViewLayout)ScreenShots
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Using1- Create instance
```swift
let snCollectionViewLayout = SNCollectionViewLayout()
snCollectionViewLayout.fixedDivisionCount = 4 // Columns for .vertical, rows for .horizontal
snCollectionViewLayout.delegate = self
myCollectionView.collectionViewLayout = snCollectionViewLayout
```2- Delegate
```swift
// scale for items based number of columns
func scaleForItem(inCollectionView collectionView: UICollectionView, withLayout layout: UICollectionViewLayout, atIndexPath indexPath: IndexPath) -> UInt {
if indexPath.row == 0 || indexPath.row == 3 || indexPath.row == 10 || indexPath.row == 70 {
return 2
}
return 1
}
// height for item if set fixedDimension height equal width
func itemFlexibleDimension(inCollectionView collectionView: UICollectionView, withLayout layout: UICollectionViewLayout, fixedDimension: CGFloat) -> CGFloat {
return fixedDimension
}
// header height
func headerFlexibleDimension(inCollectionView collectionView: UICollectionView, withLayout layout: UICollectionViewLayout, fixedDimension: CGFloat) -> CGFloat {
return 0
}
```## Requirements
* Swift 4.2+
* Xcode 10.0+
* iOS 11.0+## Installation
SNCollectionViewLayout is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'SNCollectionViewLayout'
```## Author
ahmedAlmasri, [email protected]
## License
SNCollectionViewLayout is available under the MIT license. See the LICENSE file for more info.