Remove space between sections in collectionview

Here's the Swift 4.2 version.

This lets you set various inset configurations for different sections.

/// Formats the insets for the various headers and sections.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
    if section == 0 {
        // No insets for header in section 0
        return UIEdgeInsets.zero
    } else {
        // Normal insets for collection
        return UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
    }
}

Header height can be adjusted by adjusting the params of the collection view layout. Following is the code which works perfectly fine.

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 
{
    if ([[sectionHeaderArray objectAtIndex:section] boolValue]) {
        return UIEdgeInsetsMake(10, 10, 10, 10);
    }
      return UIEdgeInsetsZero;
}

You can use the method to implement this:

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

    if ([[sectionHeaderStatusArray objectAtIndex:section] boolValue]) {
        return UIEdgeInsetsMake(23, 19, 46, 14);
    }

      return UIEdgeInsetsZero;
}