0413--iOS之UICollectionViewCell类

Class

UICollectionViewCell

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

         --UICollectionViewCell是collection view中的可见范围内的单个数据项的表示。

 

Declaration

class UICollectionViewCell : UICollectionReusableView           --继承于UICollectionReusableView 

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.

              --你可以按原样使用UICollectionViewCell或将其子类化以添加其他属性和方法。cell的布局和表示是由collection view及其相应的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.

            --若要配置cell的外观,请将“需要显示数据的相关视图内容”作为子视图添加到cell的contentView属性中。不要直接将子视图添加到cell的本身。cell管理多个内容层,但是“内容”视图content view只能一个。除“内容”视图外,单元格还管理两个背景视图,这两个视图是cell选定和未选定状态下的背景显示。

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 dequeueReusableCell(withReuseIdentifier:for:) method of the collection view object to retrieve one.

      --通常你不需要自己创建该类的实例。取而代之,你可以使用collection view object来注册指定的cell子类(或包含类的已配置实例的nib文件)。当您需要一个cell类的新实例时,调用collection view object的dequeueReusableCell(withReuseIdentifier:for:)方法来获取实例。

 

Topics                 --专题

Accessing the Cell’s Views                     --访问cell的view

var contentView: UIView

The main view to which you add your cell’s custom content.

var backgroundView: UIView?

The view that is displayed behind the cell’s other content.

var selectedBackgroundView: UIView?

The view that is displayed just above the background view when the cell is selected.

 

Managing the Cell’s State                            --管理cell的状态

var isSelected: Bool

The selection state of the cell.

var isHighlighted: Bool

The highlight state of the cell.

 

Managing Drag State Changes                          --管理拖动状态的变化

func dragStateDidChange(UICollectionViewCell.DragState)

Called when the drag state of the cell changes.

enum UICollectionViewCell.DragState

Constants indicating the current state of the drag operation.

 

Relationships             --继承关系

Inherits From

UICollectionReusableView

Conforms To

See Also

Cells

class UICollectionReusableView

A view that defines the behavior for all cells and supplementary views presented by a collection view.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值