Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cells are not centralizing #26

Open
cs-joao-souza opened this issue Nov 1, 2017 · 4 comments
Open

Cells are not centralizing #26

cs-joao-souza opened this issue Nov 1, 2017 · 4 comments

Comments

@cs-joao-souza
Copy link

My cells are not centralizing and have no ideia why.

Do i need to do something special?

@dipkasyap
Copy link

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

@dubraf
Copy link

dubraf commented Nov 17, 2017

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 :)

@Ricardo1980
Copy link

Are you having this problem?
#32

@armandsLa
Copy link

armandsLa commented Oct 9, 2020

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)
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants