How to achieve page spacing in a UICollectionView?

UICollection has a paging like UIPageViewController. With the latter, you have a UIPageViewControllerOptionInterPageSpacingKey to easily set the interval. How is this achieved with a UICollectionView?

+4
source share
2 answers

Perhaps you can explicitly do it with UICollectionViewLayoutAttributes, but my approach (which works for collection views and my own scroll views related to the view) is to split cells without spacing (which makes the math of the layout simple), but make transparent cells.

, .

+3

collectionView:layout:insetForSectionAtIndex: UICollectionView. ...

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(top, left, bottom, right);
}

: UICollectionView by @michael23

+1

Source: https://habr.com/ru/post/1546355/


All Articles