قالب وردپرس درنا توس
Home / IOS Development / The collection view line last row appears differently in spite of equal widths – fast iOS

The collection view line last row appears differently in spite of equal widths – fast iOS



I have a fixed grid of collection display cells (UICollectionView), but the cells in the bottom row always appear with a slightly smaller width on the screen. The frame format (or boundaries) and the calculated width used in collectionViewLayout: UICollectionViewLayout sizeForItemAt is the same for all rows.

  enter image description here

          func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
{
leave settings = currentContents [indexPath.item]
la height = CGFloat (30)

// https://stackoverflow.com/questions/5491
5227/uicollectionview-remove-space-between-cells-with-7-items-per-row was cellWidth = CGFloat () la availableWidth = collectionView.bounds.size.width print ("available width", available width) leave minimumWidth = floor (availableWidth / collectionContents.cellsPerRow5) print ("minmum width", minimum width) cellWidth = minimumWidth * settings.portion - 1 print ("cell width", cell width) return CGSize (width: cell width, height: height) }

  enter picture description here

I would like to get the bottom line to line up with the other rows, but can't imagine what happens that changes the widths after returning the value in the layout delegate method (or how to fix).


Source link