Skip to content

Latest commit

 

History

History
489 lines (323 loc) · 13.1 KB

CollectionView.md

File metadata and controls

489 lines (323 loc) · 13.1 KB

CollectionView

@available(iOS 11, *) public class CollectionView: UICollectionView

Inheritance

UICollectionView, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout

Initializers

init(initialData:)

public init(initialData: [[CellDisplayable]] = [[CellDisplayable]]())

Properties

data

var data: [[CellDisplayable]]

Methods

set(delegateTo:)

Set a new delegate for CollectionView. All modifiers depending on delegate will do nothing after calling that.

@discardableResult func set(delegateTo delegate: UICollectionViewDelegate) -> Self

set(dataSourceTo:)

Set a new delegate for CollectionView. All modifiers depending on data source will do nothing after calling that.

@discardableResult func set(dataSourceTo dataSource: UICollectionViewDataSource) -> Self

set(layout:)

Set a new layout for collection view.

@discardableResult func set(layout: UICollectionViewLayout) -> Self

update(shouldReloadData:_:)

@discardableResult func update(shouldReloadData: Bool = false, _ closure: ([[CellDisplayable]]) -> [[CellDisplayable]]) -> Self

append(shouldReloadData:_:)

@discardableResult func append(shouldReloadData: Bool = false, _ closure: () -> [[CellDisplayable]]) -> Self

prefetchingEnabled(_:)

@discardableResult func prefetchingEnabled(_ bool: Bool) -> Self

prefetchDataSource(_:)

@discardableResult func prefetchDataSource(_ prefetchDataSource: () -> (UICollectionViewDataSourcePrefetching)) -> Self

register(cells:)

@discardableResult func register(cells: [CollectionViewCell.Type]) -> Self

insertItems(at:)

@discardableResult func insertItems(at indexPaths: [IndexPath]) -> Self

insertItem(at:)

@discardableResult func insertItem(at indexPath: IndexPath) -> Self

moveItem(at:to:)

@discardableResult func moveItem(at sourceIndexPath: IndexPath, to targetIndexPath: IndexPath) -> Self

moveItems(at:to:)

@discardableResult func moveItems(at sourceIndexPaths: [IndexPath], to targetIndexPaths: [IndexPath]) -> Self

deleteItem(at:)

@discardableResult func deleteItem(at indexPath: IndexPath) -> Self

deleteItems(at:)

@discardableResult func deleteItems(at indexPaths: [IndexPath]) -> Self

scrollToItem(at:at:animated:)

@discardableResult func scrollToItem(at indexPath: IndexPath, at position: UICollectionView.ScrollPosition, animated: Bool = true) -> Self

allowSelection(_:multiple:)

@discardableResult func allowSelection(_ bool: Bool, multiple: Bool = false) -> Self

selectItem(at:animated:scrollPosition:)

@discardableResult func selectItem(at indexPath: IndexPath, animated: Bool, scrollPosition: UICollectionView.ScrollPosition) -> Self

deselectItem(at:animated:)

@discardableResult func deselectItem(at indexPath: IndexPath, animated: Bool) -> Self

insertSections(at:)

@discardableResult func insertSections(at indexSet: IndexSet) -> Self

moveSection(from:to:)

@discardableResult func moveSection(from section: Int, to newSection: Int) -> Self

deleteSections(at:)

@discardableResult func deleteSections(at sections: IndexSet) -> Self

set(backgroundView:)

@discardableResult func set(backgroundView: UIView) -> Self

setNumberOfItemsInSection(handler:)

@discardableResult func setNumberOfItemsInSection(handler: @escaping ((UICollectionView, Int) -> Int)) -> Self

Parameters

  • handler: Contains actually declared collection view and given section, expects to return number of items for given section.

configureCell(handler:)

@discardableResult func configureCell(handler: @escaping ((UICollectionView, IndexPath) -> UICollectionViewCell)) -> Self

setSectionTitles(shouldReloadData:to:)

Set index titles for CollectionView

@discardableResult func setSectionTitles(shouldReloadData: Bool = false, to array: [String]) -> Self

Parameters

  • array: Used to provide titles for Collection View, order used is the same as the order of parameter.

numberOfSections(in:)

public func numberOfSections(in collectionView: UICollectionView) -> Int

collectionView(_:numberOfItemsInSection:)

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int

collectionView(_:cellForItemAt:)

public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell

indexTitles(for:)

public func indexTitles(for collectionView: UICollectionView) -> [String]?

collectionView(_:indexPathForIndexTitle:at:)

public func collectionView(_ collectionView: UICollectionView, indexPathForIndexTitle title: String, at index: Int) -> IndexPath

shouldSelectItem(_:)

@discardableResult func shouldSelectItem(_ handler: @escaping ((IndexPath) -> Bool)) -> Self

didSelectItemAt(_:)

@discardableResult func didSelectItemAt(_ handler: @escaping ((IndexPath) -> ())) -> Self

shouldDeselectItemAt(_:)

@discardableResult func shouldDeselectItemAt(_ handler: @escaping ((IndexPath) -> Bool)) -> Self

didDeselectItemAt(_:)

@discardableResult func didDeselectItemAt(_ handler: @escaping ((IndexPath) -> ())) -> Self

shouldBeginMultipleSelectionInteractionAt(_:)

@discardableResult func shouldBeginMultipleSelectionInteractionAt(_ handler: @escaping ((IndexPath) -> Bool)) -> Self

didBeginMultipleSelectionInteractionAt(_:)

@discardableResult func didBeginMultipleSelectionInteractionAt(_ handler: @escaping ((IndexPath) -> ())) -> Self

didEndMultipleSelectionSelectionInteraction(_:)

@discardableResult func didEndMultipleSelectionSelectionInteraction(_ handler: @escaping ((UICollectionView) -> ())) -> Self

shouldHighlightItemAt(_:)

@discardableResult func shouldHighlightItemAt(_ handler: @escaping ((IndexPath) -> Bool)) -> Self

didHighlightItemAt(_:)

@discardableResult func didHighlightItemAt(_ handler: @escaping ((IndexPath) -> ())) -> Self

didUnhighlightItemAt(_:)

@discardableResult func didUnhighlightItemAt(_ handler: @escaping ((IndexPath) -> ())) -> Self

willDisplayCellHandlerFor(_:)

@discardableResult func willDisplayCellHandlerFor(_ handler: @escaping ((CollectionViewCell, IndexPath) -> ())) -> Self

didEndDisplayingCellFor(_:)

@discardableResult func didEndDisplayingCellFor(_ handler: @escaping ((CollectionViewCell, IndexPath) -> ())) -> Self

transitionLayoutFor(_:)

@discardableResult func transitionLayoutFor(_ handler: @escaping (_ old: UICollectionViewLayout, _ new: UICollectionViewLayout) -> UICollectionViewTransitionLayout) -> Self

targetContentOffsetFor(_:)

@discardableResult func targetContentOffsetFor(_ handler: @escaping (_ proposed: CGPoint) -> CGPoint) -> Self

targetIndexPathForMove(_:)

@discardableResult func targetIndexPathForMove(_ handler: @escaping (_ from: IndexPath, _ to: IndexPath) -> IndexPath) -> Self

canFocusItemAt(_:)

@discardableResult func canFocusItemAt(_ handler: @escaping (IndexPath) -> Bool) -> Self

collectionView(_:shouldSelectItemAt:)

public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool

collectionView(_:didSelectItemAt:)

public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)

collectionView(_:shouldDeselectItemAt:)

public func collectionView(_ collectionView: UICollectionView, shouldDeselectItemAt indexPath: IndexPath) -> Bool

collectionView(_:didDeselectItemAt:)

public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)

collectionView(_:shouldBeginMultipleSelectionInteractionAt:)

public func collectionView(_ collectionView: UICollectionView, shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool

collectionView(_:didBeginMultipleSelectionInteractionAt:)

public func collectionView(_ collectionView: UICollectionView, didBeginMultipleSelectionInteractionAt indexPath: IndexPath)

collectionViewDidEndMultipleSelectionInteraction(_:)

public func collectionViewDidEndMultipleSelectionInteraction(_ collectionView: UICollectionView)

collectionView(_:shouldHighlightItemAt:)

public func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool

collectionView(_:didHighlightItemAt:)

public func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath)

collectionView(_:didUnhighlightItemAt:)

public func collectionView(_ collectionView: UICollectionView, didUnhighlightItemAt indexPath: IndexPath)

collectionView(_:willDisplay:forItemAt:)

public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)

collectionView(_:didEndDisplaying:forItemAt:)

public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath)

collectionView(_:transitionLayoutForOldLayout:newLayout:)

public func collectionView(_ collectionView: UICollectionView, transitionLayoutForOldLayout fromLayout: UICollectionViewLayout, newLayout toLayout: UICollectionViewLayout) -> UICollectionViewTransitionLayout

collectionView(_:targetContentOffsetForProposedContentOffset:)

public func collectionView(_ collectionView: UICollectionView, targetContentOffsetForProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint

collectionView(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:)

public func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath

collectionView(_:canFocusItemAt:)

public func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool

layoutSizeForItem(_:)

@discardableResult func layoutSizeForItem(_ handler: @escaping ((UICollectionViewLayout,  IndexPath) -> CGSize)) -> Self

sectionInsets(shouldUpdate:insets:)

@discardableResult func sectionInsets(shouldUpdate: Bool = true, insets: [UIEdgeInsets]) -> Self

minimumLineSpacing(shouldUpdate:forSections:)

@discardableResult func minimumLineSpacing(shouldUpdate: Bool = true, forSections spacings: [CGFloat]) -> Self

minimumInteritemSpacing(shouldUpdate:forSections:)

@discardableResult func minimumInteritemSpacing(shouldUpdate: Bool = true, forSections spacings: [CGFloat]) -> Self

headerSize(shouldUpdate:forSections:)

@discardableResult func headerSize(shouldUpdate: Bool = true, forSections sizes: [CGSize]) -> Self

footerSize(shouldUpdate:forSections:)

@discardableResult func footerSize(shouldUpdate: Bool = true, forSections sizes: [CGSize]) -> Self

collectionView(_:layout:sizeForItemAt:)

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize

collectionView(_:layout:insetForSectionAt:)

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets

collectionView(_:layout:minimumLineSpacingForSectionAt:)

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat

collectionView(_:layout:minimumInteritemSpacingForSectionAt:)

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat

collectionView(_:layout:referenceSizeForHeaderInSection:)

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize

collectionView(_:layout:referenceSizeForFooterInSection:)

public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize