简体   繁体   中英

How can I center UICollectionViewFlowLayout with two columns

I have a UICollectionView where I want this:

[    x    x    ]
[    x    x    ]

Each UICollectionViewCell is 120x120 using:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(120, 120);
}

I cannot figure out how to make the two columns center. With the same amount in the left, middle and right.

Can you help me out with this?

Thanks!

Use sectionInset to dictate the margins. Use minimumInteritemSpacing to determine the space between the items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM