UICollectionViewCell Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 6.0 and later. |
| Declared in | UICollectionViewCell.h |
Overview
A UICollectionViewCell object presents the content for a single data item when that item is within the collection view’s visible bounds. You can use this class 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 appearance of your cell, add the views needed to present the data item’s content as subviews to the view in the contentView property. Do not 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 do not create instances of this class yourself. Instead, you register your specific cell subclass (or a nib file containing a configured instance of your class) with the collection view object. When you want a new instance of your cell class, call the dequeueReusableCellWithReuseIdentifier:forIndexPath: method of the collection view object to retrieve one.
Tasks
Accessing the Cell’s Views
-
contentViewproperty -
backgroundViewproperty -
selectedBackgroundViewproperty
Managing the Cell’s State
-
selectedproperty -
highlightedproperty
Properties
backgroundView
The view that is displayed behind the cell’s other content.
Discussion
Use this property to assign a custom background view to the cell. The background view is placed behind the content view and its frame is automatically adjusted so that it fills the bounds of the cell.
Availability
- Available in iOS 6.0 and later.
Declared In
UICollectionViewCell.hcontentView
The main view to which you add your cell’s custom content. (read-only)
Discussion
When configuring a cell, you add any custom views representing your cell’s content to this view. The cell object places the content in this view in front of any background views.
Availability
- Available in iOS 6.0 and later.
Declared In
UICollectionViewCell.hhighlighted
The highlight state of the cell.
Discussion
This property manages the highlight state of the cell only. The default value of this property is NO, which indicates that the cell is not highlighted.
You typically do not set the value of this property directly. Instead, the preferred way to select the cell and highlight it is to use the selection methods of the collection view object.
Availability
- Available in iOS 6.0 and later.
Declared In
UICollectionViewCell.hselected
The selection state of the cell.
Discussion
This property manages the selection state of the cell only. The default value of this property is NO, which indicates that the cell is not selected.
You typically do not set the value of this property directly. Changing the value of this property programmatically does not change the appearance of the cell. The preferred way to select the cell and highlight it is to use the selection methods of the collection view object.
Availability
- Available in iOS 6.0 and later.
Declared In
UICollectionViewCell.hselectedBackgroundView
The view that is displayed just above the background view when the cell is selected.
Discussion
You can use this view to give the cell a custom appearance when it is selected. When the cell is selected, this view is layered above the backgroundView and behind the contentView.
Availability
- Available in iOS 6.0 and later.
Declared In
UICollectionViewCell.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)