-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
Hi,
I have a collectionView with vertical flow layout that contains the header and shows two cells in a row, the following code will return incorrect y pos in one of the cell:
Line 303:
switch verticalAlignment {
case .top:
let minY = layoutAttributes.reduce(CGFloat.greatestFiniteMagnitude) { min($0, $1.frame.minY) }
return AlignmentAxis(alignment: .top, position: minY)
I found out the issue is caused by the UICollectionElementKindSectionHeader contains in the layoutAttributes array and affected the result of minY.
Here is my quick fix:
let filteredLayoutAttributes = layoutAttributes.filter { layoutAttribute in
return layoutAttribute.representedElementCategory == .cell
}
let minY = filteredLayoutAttributes.reduce(CGFloat.greatestFiniteMagnitude) { min($0, $1.frame.minY) }
return AlignmentAxis(alignment: .top, position: minY)
nkezhaya, avidrush94, yojkim, feelsodev, popei69 and 6 more
Metadata
Metadata
Assignees
Labels
No labels