@@ -13,7 +13,7 @@ class CLCollectionViewFlowLayout: UICollectionViewFlowLayout {
1313 //MARK: - props
1414 //item动态宽高则必须实现该协议
1515 weak var delegate : UICollectionViewDelegateFlowLayout ?
16-
16+
1717 private var itemAttributes = [ UICollectionViewLayoutAttributes] ( )
1818 private var sectionHeaderAttributes = [ UICollectionViewLayoutAttributes] ( )
1919 private var sectionFooterAttributes = [ UICollectionViewLayoutAttributes] ( )
@@ -22,7 +22,7 @@ class CLCollectionViewFlowLayout: UICollectionViewFlowLayout {
2222 //MARK: - private method
2323 func layoutHeaderSectionAttris( at section: Int , x: CGFloat , y: CGFloat ) -> UICollectionViewLayoutAttributes ? {
2424 if let delegate = self . delegate {
25- if delegate. responds ( to: #selector( delegate. collectionView ( _: layout: minimumLineSpacingForSectionAt : ) ) ) {
25+ if delegate. responds ( to: #selector( delegate. collectionView ( _: layout: referenceSizeForHeaderInSection : ) ) ) {
2626 let sectionSize = self . delegate!. collectionView!( collectionView!, layout: self , referenceSizeForHeaderInSection: section)
2727 var sectionHeight : CGFloat = 0
2828 if sectionSize != CGSize . zero {
@@ -76,9 +76,10 @@ class CLCollectionViewFlowLayout: UICollectionViewFlowLayout {
7676 var yOffset = self . sectionInset. top
7777 var yItemOffset = self . sectionInset. top
7878 for section in 0 ..< sectionCount {
79- let headerAttris = self . layoutHeaderSectionAttris ( at: section, x: xOffset , y: yOffset)
79+ let headerAttris = self . layoutHeaderSectionAttris ( at: section, x: 0 , y: yOffset)
8080 if headerAttris != nil {
8181 yOffset = headerAttris!. frame. maxY
82+ yItemOffset = headerAttris!. frame. maxY
8283 self . sectionHeaderAttributes. append ( headerAttris!)
8384 }
8485 var pre : CLCollectionViewLayoutAttributes ?
@@ -118,7 +119,7 @@ class CLCollectionViewFlowLayout: UICollectionViewFlowLayout {
118119 }
119120 yItemOffset = layoutAttributes. frame. minY
120121 }
121- if let footerAttris = self . layoutFooterSectionAttris ( at: section, x: self . sectionInset . left , y: yOffset) {
122+ if let footerAttris = self . layoutFooterSectionAttris ( at: section, x: 0 , y: yOffset) {
122123 yOffset = footerAttris. frame. maxY
123124 self . sectionFooterAttributes. append ( footerAttris)
124125 }
@@ -185,5 +186,5 @@ class CLCollectionViewFlowLayout: UICollectionViewFlowLayout {
185186 return true
186187 }
187188
188-
189+
189190}
0 commit comments