diff --git a/PinterestLayout/PinterestLayout.swift b/PinterestLayout/PinterestLayout.swift index 8554de7..f22826d 100644 --- a/PinterestLayout/PinterestLayout.swift +++ b/PinterestLayout/PinterestLayout.swift @@ -25,7 +25,8 @@ public class PinterestLayout: UICollectionViewLayout { /** Cell padding. */ - public var cellPadding: CGFloat = 0 + public var cellPaddingTop: CGFloat = 0 + public var cellPaddingSide: CGFloat = 0 private var cache = [PinterestLayoutAttributes]() @@ -76,7 +77,7 @@ public class PinterestLayout: UICollectionViewLayout { override public func prepare() { if cache.isEmpty { let collumnWidth = contentWidth / CGFloat(numberOfColumns) - let cellWidth = collumnWidth - (cellPadding * 2) + let cellWidth = collumnWidth - (cellPaddingSide * 2) var xOffsets = [CGFloat]() @@ -129,7 +130,7 @@ public class PinterestLayout: UICollectionViewLayout { heightForAnnotationAtIndexPath: indexPath, withWidth: cellWidth ) - let cellHeight = cellPadding + imageHeight + annotationHeight + cellPadding + let cellHeight = cellPaddingTop + imageHeight + annotationHeight + cellPaddingTop let frame = CGRect( x: xOffsets[column], @@ -138,7 +139,7 @@ public class PinterestLayout: UICollectionViewLayout { height: cellHeight ) - let insetFrame = frame.insetBy(dx: cellPadding, dy: cellPadding) + let insetFrame = frame.insetBy(dx: cellPaddingSide, dy: cellPaddingTop) let attributes = PinterestLayoutAttributes( forCellWith: indexPath ) diff --git a/PinterestLayout/PinterestVC.swift b/PinterestLayout/PinterestVC.swift index 8694d8a..6671206 100644 --- a/PinterestLayout/PinterestVC.swift +++ b/PinterestLayout/PinterestVC.swift @@ -73,7 +73,8 @@ open class PinterestVC: UICollectionViewController, PinterestLayoutDelegate { return layout }() layout.delegate = self - layout.cellPadding = 5 + layout.cellPaddingTop = 5 + layout.cellPaddingSide = 5 layout.numberOfColumns = 2 } diff --git a/PinterestLayoutExample/CustomCollectionVC.swift b/PinterestLayoutExample/CustomCollectionVC.swift index c097872..8c62a0c 100644 --- a/PinterestLayoutExample/CustomCollectionVC.swift +++ b/PinterestLayoutExample/CustomCollectionVC.swift @@ -51,7 +51,8 @@ class CustomCollectionVC: UICollectionViewController { return layout }() layout.delegate = self - layout.cellPadding = 5 + layout.cellPaddingTop = 5 + layout.cellPaddingSide = 5 layout.numberOfColumns = 2 } }