@@ -53,6 +53,10 @@ private func > <T: Comparable>(lhs: T?, rhs: T?) -> Bool {
53
53
@objc optional func collectionView( _ collectionView: UICollectionView ,
54
54
layout collectionViewLayout: UICollectionViewLayout ,
55
55
columnCountFor section: Int ) -> Int
56
+
57
+ @objc optional func collectionView( _ collectionView: UICollectionView ,
58
+ layout collectionViewLayout: UICollectionViewLayout ,
59
+ minimumColumnSpacingFor section: Int ) -> CGFloat
56
60
57
61
@available ( * , unavailable, renamed: " collectionView(_:layout:sizeForItemAt:) " )
58
62
@objc optional func collectionView ( _ collectionView: UICollectionView , layout collectionViewLayout: UICollectionViewLayout ,
@@ -205,10 +209,13 @@ public class CHTCollectionViewWaterfallLayout: UICollectionViewLayout {
205
209
}
206
210
207
211
public func itemWidth( inSection section: Int ) -> CGFloat {
208
- let columnCount = self . columnCount ( forSection: section)
209
- let spaceColumCount = CGFloat ( columnCount - 1 )
210
212
let width = collectionViewContentWidth ( ofSection: section)
211
- return floor ( ( width - ( spaceColumCount * minimumColumnSpacing) ) / CGFloat( columnCount) )
213
+
214
+ let columnCount = self . columnCount ( forSection: section)
215
+ let spaceColumnCount = CGFloat ( columnCount - 1 )
216
+ let columnSpacing = delegate? . collectionView ? ( collectionView!, layout: self , minimumColumnSpacingFor: section) ?? minimumColumnSpacing
217
+
218
+ return floor ( ( width - ( spaceColumnCount * columnSpacing) ) / CGFloat( columnCount) )
212
219
}
213
220
214
221
override public func prepare( ) {
0 commit comments