boundarySupplementaryItems
Nig0l opened this issue · 2 comments
Nig0l commented
if you change layout dynamically and those layouts have headers than the content offset of a collection after animation and correct drawing suddenly jumps to incorrect value.
do know how to resolve this issue or its normal behaviour:)?
as an example I've made small changes to SimpleGridViewController
override func createLayout() -> UICollectionViewLayout {
let itemSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(gridItemSize.rawValue),
heightDimension: .fractionalHeight(1.0)
)
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalWidth(gridItemSize.rawValue)
)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(44))
let headerElement = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: UICollectionView.elementKindSectionHeader, alignment: .top)
section.boundarySupplementaryItems = [headerElement]
let layout = UICollectionViewCompositionalLayout(section: section)
return layout
}
Nig0l commented
have found the reason of that issue:
.estimated(44) makes this mess
use absolute value : )
nemecek-filip commented
Great! Glad to hear!