---
title: "preferredLayoutAttributesFitting(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uicollectionreusableview/preferredlayoutattributesfitting(_:)"
---

# preferredLayoutAttributesFitting(_:)

Gives the cell a chance to modify the attributes provided by the layout object.

## Declaration

```swift
func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes
```

## Parameters

- `layoutAttributes`: The attributes provided by the layout object. These attributes represent the values that the layout intends to apply to the cell.

## Return Value

Return Value The final attributes to apply to the cell.

## Discussion

Discussion The default implementation of this method adjusts the size values to accommodate changes made by a self-sizing cell. Subclasses can override this method and use it to adjust other layout attributes too. If you override this method and want the cell size adjustments, call super first and make your own modifications to the returned attributes.

## See Also

### Managing layout changes

- [apply(_:)](uikit/uicollectionreusableview/apply(_:).md)
- [willTransition(from:to:)](uikit/uicollectionreusableview/willtransition(from:to:).md)
- [didTransition(from:to:)](uikit/uicollectionreusableview/didtransition(from:to:).md)
