Very strange issue on UICollectionView...
I have a UIImageView below a UICollectionView and I noticed there are multiple hairline / 1px clear lines appearing at certain points in the collectionView... one appearing below a description cell...

Assuming it was a problem with the cell, I've investigated every way I could think with no joy. I've doubled up this cell to illustrate the issue happens in between IndexPath section 1 and item 6 and 7
Even when this cell is doubled up... the divider line cell below is part of the same section so it's definitely not a footer or a header???

My flowLayout is
flowLayout.scrollDirection = .vertical
flowLayout.minimumInteritemSpacing = 0.0
flowLayout.minimumLineSpacing = 0.0
flowLayout.sectionInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
flowLayout.headerReferenceSize = .zero
flowLayout.footerReferenceSize = .zero
I made the background of the collectionView red to highlight the issue... I don't have a clue what the issue is.
View Hierarchy

Update
changing flowLayout.minimumLineSpacing = 0.0 to -1.0 'fixes' the issue in some places... why wouldn't this value remain accurate along all cells? and remain at 0.0??
flowLayout.scrollDirection = .vertical
flowLayout.minimumInteritemSpacing = 0.0
flowLayout.minimumLineSpacing = -1.0
flowLayout.sectionInset = .zero
I've only gone and solved it... hours after putting a 300 bounty on it..
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// calculated CGSize...
return CGSize(width:collectionView.bounds.size.width,height:ceil(calculatedHeight)
}
remember @2x @3x always ceil your calculated cells... UICollectionViews can't hack 0.5 points
To add on to the answer of @Magoo:
A CGSize structure is sometimes used to represent a distance vector, rather than a physical size. As a vector, its values can be negative. To normalize a CGRect structure so that its size is represented by positive values, call the standardized function.
In Swift 2.x you will need to use:
return CGSizeMake(width:collectionView.bounds.size.width,height:ceil(calculatedHeight)
As of Swift 3 you can no longer use CGSizeMake:
return CGSize(width:collectionView.bounds.size.width,height:ceil(calculatedHeight)
ceil function rounds a number UP to the nearest integer, if necessary.floor.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With