---
title: "layoutAttributesForInterItemGap(before:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionviewlayout/layoutattributesforinteritemgap(before:)"
---

# layoutAttributesForInterItemGap(before:)

Returns layout attributes for the inter-item gap at the specified location in your layout.

## Declaration

```swift
func layoutAttributesForInterItemGap(before indexPath: IndexPath) -> NSCollectionViewLayoutAttributes?
```

## Parameters

- `indexPath`: The index path of the item that follows the inter-item gap. For a gap that follows the last item in the section, set the item property to the total number of items in the section.

## Return Value

Return Value A layout attributes object containing the layout information to apply to the inter-item gap, or nil if no attributes are available.

## Discussion

Discussion The default implementation of this method returns nil. Subclasses can override this method to provide layout attributes for inter-item gaps. In your implementation, use the specified index path to compute the location of the gap in collection view’s content. If the gap represents a valid location, use the init(forInterItemGapBefore:) class method of NSCollectionViewLayoutAttributes to create a new layout attributes object and set the frame property to the rectangle you computed.

## See Also

### Providing Layout Information

- [layoutAttributesClass](appkit/nscollectionviewlayout/layoutattributesclass.md)
- [prepare()](appkit/nscollectionviewlayout/prepare().md)
- [collectionViewContentSize](appkit/nscollectionviewlayout/collectionviewcontentsize.md)
- [layoutAttributesForElements(in:)](appkit/nscollectionviewlayout/layoutattributesforelements(in:).md)
- [layoutAttributesForItem(at:)](appkit/nscollectionviewlayout/layoutattributesforitem(at:).md)
- [layoutAttributesForSupplementaryView(ofKind:at:)](appkit/nscollectionviewlayout/layoutattributesforsupplementaryview(ofkind:at:).md)
- [layoutAttributesForDecorationView(ofKind:at:)](appkit/nscollectionviewlayout/layoutattributesfordecorationview(ofkind:at:).md)
- [layoutAttributesForDropTarget(at:)](appkit/nscollectionviewlayout/layoutattributesfordroptarget(at:).md)
- [targetContentOffset(forProposedContentOffset:)](appkit/nscollectionviewlayout/targetcontentoffset(forproposedcontentoffset:).md)
- [targetContentOffset(forProposedContentOffset:withScrollingVelocity:)](appkit/nscollectionviewlayout/targetcontentoffset(forproposedcontentoffset:withscrollingvelocity:).md)
