ReusableViewConfig
public struct ReusableViewConfig<Item, Cell> : ReusableViewConfigProtocol where Cell : ReusableViewProtocol
A ReusableViewConfig
is a concrete ReusableViewConfigProtocol
type.
This config is responsible for producing and configuring reusable views for a specific item.
Cells can be for either collection views or table views.
-
Configures the cell for the specified item, parent view, and index path.
Declaration
Swift
public typealias ViewConfigurator = (Cell, Item?, ReusableViewType, Cell.ParentView, IndexPath) -> Cell
Parameters
cell
The cell to be configured at the index path.
item
The item at
indexPath
.type
The type of reusable view.
parentView
The collection view or table view requesting this information.
indexPath
The index path at which the cell will be displayed.
Return Value
The configured cell.
-
A unique identifier that describes the purpose of the cells that the config produces. The config dequeues cells from the collection view or table view with this reuse identifier.
Note
Clients are responsible for registering a cell for this identifier with the collection view or table view.Declaration
Swift
public let reuseIdentifier: String
-
The type of the reusable view.
Declaration
Swift
public let type: ReusableViewType
-
A closure used to configure the views.
Declaration
Swift
public let viewConfigurator: ViewConfigurator
-
Constructs a new reusable view config.
Declaration
Swift
public init(reuseIdentifier: String, type: ReusableViewType = .cell, viewConfigurator: @escaping ViewConfigurator)
Parameters
reuseIdentifier
The reuse identifier with which to dequeue reusable views.
type
The type of the reusable view.
viewConfigurator
The closure with which to configure views.