UPCarouselFlowLayout
UPCarouselFlowLayout copied to clipboard
Cells are not centralizing
My cells are not centralizing and have no ideia why.
Do i need to do something special?
Same Here Cannot centralize LAST & FIRST , if i make my own design ! Please provide updated info on this issue if possible !
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 :)
Are you having this problem? https://github.com/ink-spot/UPCarouselFlowLayout/issues/32
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)
}