DynamicListCollectionViewFlowLayout

open class DynamicListCollectionViewFlowLayout : UICollectionViewFlowLayout

A CollectionViewFlowLayout that resembles a table view with dynamic height sizing.

This flow layout mimics a table view layout with dynamic height sizing. It has minimumLineSpacing and minimumInteritemSpacing set to 10.

Collection view cells used in this layout must override the preferredLayoutAttributesFitting(_:) method to calculate the appropriate height for the cell. One way of doing this is the following:

override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
    let layoutAttributes = super.preferredLayoutAttributesFitting(layoutAttributes)
    layoutIfNeeded()
    layoutAttributes.frame.size = systemLayoutSizeFitting(UIView.layoutFittingCompressedSize,
                                                          withHorizontalFittingPriority: .required,
                                                          verticalFittingPriority: .fittingSizeLevel)
    return layoutAttributes
}
  • Undocumented

    Declaration

    Swift

    override public init()
  • Undocumented

    Declaration

    Swift

    public required init?(coder aDecoder: NSCoder)
  • Undocumented

    Declaration

    Swift

    override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]?
  • Undocumented

    Declaration

    Swift

    override open func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes?
  • Undocumented

    Declaration

    Swift

    override open func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool