UPCarouselFlowLayout icon indicating copy to clipboard operation
UPCarouselFlowLayout copied to clipboard

Cells are not centralizing

Open cs-joao-souza opened this issue 7 years ago • 4 comments

My cells are not centralizing and have no ideia why.

Do i need to do something special?

cs-joao-souza avatar Nov 01 '17 16:11 cs-joao-souza

Same Here Cannot centralize LAST & FIRST , if i make my own design ! Please provide updated info on this issue if possible !

dipkasyap avatar Nov 14 '17 05:11 dipkasyap

I had the same problem when I was using : func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize The solution was adding sectionInset for the layout inside above method :)

dubraf avatar Nov 17 '17 09:11 dubraf

Are you having this problem? https://github.com/ink-spot/UPCarouselFlowLayout/issues/32

Ricardo1980 avatar Feb 06 '18 11:02 Ricardo1980

Looks like this is being caused when section insets are not taken into account when sizing the cell. Subtracting them from item size fixes the issue.

func collectionView(_ collectionView: UICollectionView,
                        layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        let layout = collectionViewLayout as! UICollectionViewFlowLayout
        var height = collectionView.frame.height
        height -= layout.sectionInset.top + layout.sectionInset.bottom
        return CGSize(width: height, height: height)
    }

armandsLa avatar Oct 09 '20 11:10 armandsLa