<!--
{
  "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/init(forSupplementaryViewOfKind:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICollectionViewLayoutAttributes(cm)layoutAttributesForSupplementaryViewOfKind:withIndexPath:"
  },
  "title" : "init(forSupplementaryViewOfKind:with:)"
}
-->

# init(forSupplementaryViewOfKind:with:)

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

```
convenience init(forSupplementaryViewOfKind elementKind: String, with indexPath: IndexPath)
```

## Parameters

`elementKind`

A string that identifies the type of supplementary view.

`indexPath`

The index path of the view.

## Return Value

A new layout attributes object whose precise type matches the type of the class used to call this method.

## Discussion

Use this method to create a layout attributes object for a supplementary view in the collection view. Like cells, supplementary views present data that is managed by the collection view’s data source. But unlike cells, supplementary views are typically designed for a special purpose. For example, header and footer views are laid out differently than cells and can be provided for individual sections or for the collection view as a whole.

It is up to you to decide how to use the `indexPath` parameter to identify a given supplementary view. Typically, you use the `elementKind` parameter to identify the type of the supplementary view and the `indexPath` information to distinguish between different instances of that view.

---

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)