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

# UICollectionViewLayoutAttributes

A layout object that manages the layout-related attributes for a given item in a collection view.

```
@MainActor class UICollectionViewLayoutAttributes
```

## Overview

Layout objects create instances of this class when asked to do so by the collection view. In turn, the collection view uses the layout information to position cells and supplementary views inside its bounds.

### Subclassing notes

In most cases, you use this class as-is. If you want to supplement the base layout attributes with custom layout attributes, you can subclass and define whatever properties you want to store the additional layout data. Because layout attribute objects may be copied by the collection view, make sure your subclass conforms to the <doc://com.apple.documentation/documentation/Foundation/NSCopying> protocol by implementing any methods appropriate for copying your custom attributes to new instances of your subclass. In addition to defining your subclass, your [`UICollectionReusableView`](/documentation/UIKit/UICollectionReusableView) objects need to implement the [`apply(_:)`](/documentation/UIKit/UICollectionReusableView/apply(_:)) method so that they can apply any custom attributes at layout time.

If you subclass and implement any custom layout attributes, you must also override the inherited `isEqual:` method to compare the values of your properties. In iOS 7 and later, the collection view doesn’t apply layout attributes if those attributes have not changed. It determines whether the attributes have changed by comparing the old and new attribute objects using the `isEqual:` method. Because the default implementation of this method checks only the existing properties of this class, you must implement your own version of the method to compare any additional properties. If your custom properties are all equal, call `super` and return the resulting value at the end of your implementation.

## Topics

### Creating layout attributes

[`convenience init(forCellWith: IndexPath)`](/documentation/UIKit/UICollectionViewLayoutAttributes/init(forCellWith:))

Creates and returns a layout attributes object that represents a cell with the specified index path.

[`convenience init(forSupplementaryViewOfKind: String, with: IndexPath)`](/documentation/UIKit/UICollectionViewLayoutAttributes/init(forSupplementaryViewOfKind:with:))

Creates and returns a layout attributes object that represents the specified supplementary view.

[`convenience init(forDecorationViewOfKind: String, with: IndexPath)`](/documentation/UIKit/UICollectionViewLayoutAttributes/init(forDecorationViewOfKind:with:))

Creates and returns a layout attributes object that represents the specified decoration view.

### Identifying the referenced item

[`var indexPath: IndexPath`](/documentation/UIKit/UICollectionViewLayoutAttributes/indexPath)

The index path of the item in the collection view.

[`var representedElementKind: String?`](/documentation/UIKit/UICollectionViewLayoutAttributes/representedElementKind)

The layout-specific identifier for the target view.

[`var representedElementCategory: UICollectionView.ElementCategory`](/documentation/UIKit/UICollectionViewLayoutAttributes/representedElementCategory)

The type of the item.

[`enum ElementCategory`](/documentation/UIKit/UICollectionView/ElementCategory)

Constants specifying the type of view.

### Accessing the layout attributes

[`var frame: CGRect`](/documentation/UIKit/UICollectionViewLayoutAttributes/frame)

The frame rectangle of the item.

[`var bounds: CGRect`](/documentation/UIKit/UICollectionViewLayoutAttributes/bounds)

The bounds of the item.

[`var center: CGPoint`](/documentation/UIKit/UICollectionViewLayoutAttributes/center)

The center point of the item.

[`var size: CGSize`](/documentation/UIKit/UICollectionViewLayoutAttributes/size)

The size of the item.

[`var transform3D: CATransform3D`](/documentation/UIKit/UICollectionViewLayoutAttributes/transform3D)

The 3D transform of the item.

[`var transform: CGAffineTransform`](/documentation/UIKit/UICollectionViewLayoutAttributes/transform)

The affine transform of the item.

[`var alpha: CGFloat`](/documentation/UIKit/UICollectionViewLayoutAttributes/alpha)

The transparency of the item.

[`var zIndex: Int`](/documentation/UIKit/UICollectionViewLayoutAttributes/zIndex)

Specifies the item’s position on the z axis.

[`var isHidden: Bool`](/documentation/UIKit/UICollectionViewLayoutAttributes/isHidden)

Determines whether the item is currently displayed.

### Initializers

[`convenience init(forCellWithIndexPath: IndexPath)`](/documentation/UIKit/UICollectionViewLayoutAttributes/init(forCellWithIndexPath:))

[`convenience init(forDecorationViewOfKind: String, withIndexPath: IndexPath)`](/documentation/UIKit/UICollectionViewLayoutAttributes/init(forDecorationViewOfKind:withIndexPath:))

[`convenience init(forSupplementaryViewOfKind: String, withIndexPath: IndexPath)`](/documentation/UIKit/UICollectionViewLayoutAttributes/init(forSupplementaryViewOfKind:withIndexPath:))

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

[`UIDynamicItem`](/documentation/UIKit/UIDynamicItem)

### Inherits From

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

---

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)