-
Notifications
You must be signed in to change notification settings - Fork 188
Open
Labels
Description
I used stretchy Header FlowLayout
after import DisplaySwitcher my Header doesn't seem anymore?
import UIKit
class STCollectionViewFlowLayout: UICollectionViewFlowLayout {
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributes = super.layoutAttributesForElements(in: rect)
layoutAttributes?.forEach({ (attributes) in
if attributes.representedElementKind == UICollectionView.elementKindSectionHeader {
guard let collectionView = collectionView else {
return
}
let contentOffsetY = collectionView.contentOffset.y
if contentOffsetY > 0 {
return
}
let width = collectionView.frame.width
let height: CGFloat = attributes.frame.height - contentOffsetY
attributes.frame = CGRect(x: 0, y: contentOffsetY, width: width, height: height)
}
})
return layoutAttributes
}
}