YBSlantedCollectionViewLayout
public class YBSlantedCollectionViewLayout: UICollectionViewLayout
YBSlantedCollectionViewLayout is a subclass of UICollectionViewLayout allowing the display of slanted content on UICollectionView.
By default, this UICollectionViewLayout has initialize a set of properties to work as designed.
-
The slanting delta.
By default, this property is set to
50
.Parameter
Parameter slantingDelta: The slantin deltaDeclaration
Swift
@IBInspectable public var slantingDelta: UInt = 50
Parameters
slantingDelta
The slantin delta
-
Reverse the slanting angle.
Set it to
true
to reverse the slanting angle. By default, this property is set tofalse
.Parameter
Parameter reverseSlantingAngle: The slanting angle reversing statusDeclaration
Swift
@IBInspectable public var reverseSlantingAngle: Bool = false
Parameters
reverseSlantingAngle
The slanting angle reversing status
-
Allows to disable the slanting for the first cell.
Set it to
false
to disable the slanting for the first cell. By default, this property is set totrue
.Parameter
Parameter firstCellSlantingEnabled: The first cell slanting statusDeclaration
Swift
@IBInspectable public var firstCellSlantingEnabled: Bool = true
Parameters
firstCellSlantingEnabled
The first cell slanting status
-
Allows to disable the slanting for the last cell.
Set it to
false
to disable the slanting for the last cell. By default, this property is set totrue
.Parameter
Parameter lastCellSlantingEnabled: The last cell slanting statusDeclaration
Swift
@IBInspectable public var lastCellSlantingEnabled: Bool = true
Parameters
lastCellSlantingEnabled
The last cell slanting status
-
The spacing to use between two items.
The spacing to use between two items. The default value of this property is 10.0.
Parameter
Parameter lineSpacing: The spacing to use between two itemsDeclaration
Swift
@IBInspectable public var lineSpacing: CGFloat = 10
Parameters
lineSpacing
The spacing to use between two items
-
The scroll direction of the grid.
The grid layout scrolls along one axis only, either horizontally or vertically. The default value of this property is
UICollectionViewScrollDirectionVertical
.Parameter
Parameter scrollDirection: The scroll direction of the gridDeclaration
Swift
public var scrollDirection: UICollectionViewScrollDirection = UICollectionViewScrollDirection.Vertical
Parameters
scrollDirection
The scroll direction of the grid
-
Call this method to apply the slanting mask.
To apply the slanting mask on the cellView, call the this 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 }
Declaration
Swift
public func applyMaskToCellView (cellView : UICollectionViewCell, forIndexPath: NSIndexPath)
Parameters
cellView
The collection cell view
forIndexPath
The indexPath of the cell view
-
Return the size of all the content in the collection view
Declaration
Swift
override public func collectionViewContentSize() -> CGSize
-
Return true so that the layout is continuously invalidated as the user scrolls
Declaration
Swift
override public func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool
-
Perform whatever calculations are needed to determine the position of the cells and views in the layout
Declaration
Swift
override public func prepareLayout()
-
Return all attributes in the cache whose frame intersects with the rect passed to the method
Declaration
Swift
override public func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]?
-
Returns the layout attributes for the item at the specified index path.
Declaration
Swift
override public func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes?