<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSCollectionLayoutEdgeSpacing",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionLayoutEdgeSpacing"
  },
  "title" : "NSCollectionLayoutEdgeSpacing"
}
-->

# NSCollectionLayoutEdgeSpacing

An object that defines the space around the edges of items in a collection view.

```
@MainActor class NSCollectionLayoutEdgeSpacing
```

## Overview

You use edge spacing to create additional spacing around the edges of an item to adjust the position of the item in relation to its container and other items.

The leading and trailing spaces within edge spacing differ in left-to-right versus right-to-left environments. In a left-to-right environment, the leading space is on the left, and the trailing space is on the right. In a right-to-left environment, the leading space is on the right, and the trailing space is on the left. This difference ensures that your collection view layout is built with support for right-to-left languages.

The following diagram shows the difference between adding 2 points of trailing edge spacing in a left-to-right versus a right-to-left environment.

![Two diagrams that compare edge spacing in a left-to-right and a right-to-left environment. Both diagrams show a group of three square items in a row. The first diagram, labeled trailing in left-to-right environment, shows trailing space on the right of each item, implying that leading space is on the left. The second diagram, labeled trailing in right-to-left environment, shows trailing space on the left of each item, implying that leading space is on the right.](images/com.apple.uikit/media-3570381@2x.png)

## Topics

### Creating edge spacing

[`+  spacingForLeading:top:trailing:bottom:`](/documentation/UIKit/NSCollectionLayoutEdgeSpacing/init(leading:top:trailing:bottom:))

Creates an edge spacing object with the specified leading, top, trailing, and bottom spacing.

### Getting the edge spacing

[`leading`](/documentation/UIKit/NSCollectionLayoutEdgeSpacing/leading)

The leading edge spacing value.

[`top`](/documentation/UIKit/NSCollectionLayoutEdgeSpacing/top)

The top edge spacing value.

[`trailing`](/documentation/UIKit/NSCollectionLayoutEdgeSpacing/trailing)

The trailing edge spacing value.

[`bottom`](/documentation/UIKit/NSCollectionLayoutEdgeSpacing/bottom)

The bottom edge spacing value.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)