CollectionViewFlowLayout
@MainActor
open class CollectionViewFlowLayout : UICollectionViewFlowLayout
集合视图流式布局,支持纵向渲染和分页滚动效果
系统FlowLayout水平滚动时默认横向渲染,可通过本类开启纵向渲染,示例效果如下: [0 3 6 9 ] [0 1 2 3 ] [1 4 7 10] => [4 5 6 7 ] [2 5 8 11] [8 9 10 11]
-
是否启用元素纵向渲染,默认关闭,开启时需设置渲染总数itemRenderCount
Declaration
Swift
@MainActor open var itemRenderVertical: Bool
-
纵向渲染列数,开启itemRenderVertical且大于0时生效
Declaration
Swift
@MainActor open var verticalColumnCount: Int
-
纵向渲染行数,开启itemRenderVertical且大于0时生效
Declaration
Swift
@MainActor open var verticalRowCount: Int
-
计算实际渲染总数,超出部分需渲染空数据,一般numberOfItems中调用
Declaration
Swift
@MainActor open func itemRenderCount(_ itemCount: Int) -> Int
-
转换指定indexPath为纵向索引indexPath,一般无需调用
Declaration
Swift
@MainActor open func verticalIndexPath(_ indexPath: IndexPath) -> IndexPath
-
Undocumented
Declaration
Swift
@MainActor override open func prepare()
-
Undocumented
Declaration
Swift
@MainActor override open func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes?
-
Undocumented
Declaration
Swift
@MainActor override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]?
-
是否启用分页滚动,默认false。需设置decelerationRate为fast且关闭集合视图isPagingEnabled
Declaration
Swift
@MainActor open var isPagingEnabled: Bool
-
是否启用居中分页,默认false
Declaration
Swift
@MainActor open var isPagingCenter: Bool
-
获取当前页数,即居中cell的item,可能为nil
Declaration
Swift
@MainActor open var currentPage: Int? { get }
-
获取每页宽度,必须设置itemSize
Declaration
Swift
@MainActor open var pageWidth: CGFloat { get }
-
滚动到指定页数
Declaration
Swift
@MainActor open func scrollToPage(_ index: Int, animated: Bool = true)
-
Undocumented
Declaration
Swift
@MainActor override open func invalidateLayout(with context: UICollectionViewLayoutInvalidationContext)
-
Undocumented
Declaration
Swift
@MainActor override open func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint