Contents

UICollectionViewCell

A single data item when that item is within the collection view’s visible bounds.

Declaration

@MainActor class UICollectionViewCell

Overview

You can use UICollectionViewCell as-is or subclass it to add additional properties and methods. The layout and presentation of cells is managed by the collection view and its corresponding layout object.

To configure the content and appearance of your cell, you can set its contentConfiguration and backgroundConfiguration. Alternatively, add the views needed to present the data item’s content as subviews to the view in the contentView property. Don’t directly add subviews to the cell itself. The cell manages multiple layers of content, of which the content view is only one. In addition to the content view, the cell manages two background views that display the cell in its selected and unselected states.

You typically don’t create instances of this class yourself. Instead, you register your specific cell subclass (or a nib file containing a configured instance of your class) using a cell registration. When you want a new instance of your cell class, call the dequeueConfiguredReusableCell(using:for:item:) (Swift) or dequeueConfiguredReusableCellWithRegistration:forIndexPath:item: (Objective-C) method of the collection view object to retrieve one.

Topics

Configuring the background

Managing the content

Managing the state

Managing drag state changes

See Also

Cells