YBSlantedCollectionViewLayout
Overview
YBSlantedCollectionViewLayout is a subclass of UICollectionViewLayout allowing the display of slanted content on UICollectionView.
Usage
YBSlantedCollectionViewLayout contains six properties to customize the interface.
var slantingDelta: UInt
var reverseSlantingAngle: Bool
var firstCellSlantingEnabled: Bool
var lastCellSlantingEnabled: Bool
var lineSpacing: CGFloat
var scrollDirection: UICollectionViewScrollDirection
- slantingDelta is the slanting delta. Defaults to 50
- reverseSlantingAngle allows to reverse the slanting angle if the value is
true
. By default, this property is set tofalse
- firstCellSlantingEnabled allows to enable the slanting for the first cell. By default, this property is set to
true
- lastCellSlantingEnabled allows to enable the slanting for the last cell. By default, this property is set to
true
- lineSpacing is the spacing to use between two items. Defaults to 10.0
- scrollDirection is the scroll direction. Defaults to
UICollectionViewScrollDirectionVertical
Apply the slanting mask
To apply the slanting mask on the cellView, call the applyMaskToCellView
method like the following example:
func collectionView(collectionView: UICollectionView,
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell
// do something
// Apply the mask
let layout = collectionView.collectionViewLayout as! YBSlantedCollectionViewLayout
layout.applyMaskToCellView(cell, forIndexPath: indexPath)
return cell
}
Installation
YBSlantedCollectionViewLayout is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "YBSlantedCollectionViewLayout", '~> 1.0'
Todo
- [] Carthage support
- [] Improve the attribution of the clic
- [] Tests
Author
Acknowledgement
This framework is inspired by this prototype released by Matt Bridges.
License
YBSlantedCollectionViewLayout is available under the MIT license. See the LICENSE file for more info.