4

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

Doug Smith
  • 29,668
  • 57
  • 204
  • 388
  • Never used what you are asking, but as a long shot does this help http://stackoverflow.com/questions/21071043/decrease-space-between-uicollectionviewcells/21074972#21074972 – DogCoffee Jul 09 '14 at 07:53
  • @DogCoffee Not using flow layout unfortunately. – Doug Smith Jul 11 '14 at 00:13

2 Answers2

3

You can probably accomplish explicitly with UICollectionViewLayoutAttributes, but my approach (that works for collection views and my own subview-containing scroll views) is to tile the cells with no spacing (which makes the layout math simple), but make the cells transparent.

Then within each cell create a more opaque content view whose frame is an insetRect on the cell's bounds.

Kumar KL
  • 15,315
  • 9
  • 38
  • 60
danh
  • 62,181
  • 10
  • 95
  • 136
1

You can use the collectionView:layout:insetForSectionAtIndex: method for your UICollectionView. You need to add this code...

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

it was answered here: UICollectionView spacing margins by @michael23

Community
  • 1
  • 1
Steve Sahayadarlin
  • 1,164
  • 3
  • 15
  • 32