---
title: "apply(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionviewelement/apply(_:)"
---

# apply(_:)

Applies the specified layout attributes to the element.

## Declaration

```swift
@MainActor optional func apply(_ layoutAttributes: NSCollectionViewLayoutAttributes)
```

## Parameters

- `layoutAttributes`: The layout attributes to apply.

## Discussion

Discussion In your custom elements, you can use this method to apply the specified attributes to your content. For example, if your element object is a view controller, you would override this method and use it to apply the attributes to the root view object. When using your element with a layout object that supports custom attributes, you would also use this method to apply those custom attributes.

## See Also

### Managing Layout Changes

- [preferredLayoutAttributesFitting(_:)](appkit/nscollectionviewelement/preferredlayoutattributesfitting(_:).md)
- [willTransition(from:to:)](appkit/nscollectionviewelement/willtransition(from:to:).md)
- [didTransition(from:to:)](appkit/nscollectionviewelement/didtransition(from:to:).md)
