---
title: "init(forCellWith:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uicollectionviewlayoutattributes/init(forcellwith:)"
---

# init(forCellWith:)

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

## Declaration

```swift
convenience init(forCellWith indexPath: IndexPath)
```

## Parameters

- `indexPath`: The index path of the cell.

## Return Value

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

## Discussion

Discussion Use this method to create a layout attributes object for a cell in the collection view. Cells are the main type of view presented by a collection view. The index path for a cell typically includes both a section index and an item index for locating the cell’s contents in the collection view’s data source.

## See Also

### Creating layout attributes

- [init(forSupplementaryViewOfKind:with:)](uikit/uicollectionviewlayoutattributes/init(forsupplementaryviewofkind:with:).md)
- [init(forDecorationViewOfKind:with:)](uikit/uicollectionviewlayoutattributes/init(fordecorationviewofkind:with:).md)
