Skip to the content.

PTCollectionView 滚动样式指南

适用范围

PTCollectionScrollStyle 只描述主 UICollectionView 的滚动行为,PTCollectionViewType 继续负责排版。当前实现面向 iOS 17+ / Swift 6+,并复用 Core 的 Diffable、ModelStore、刷新、骨架和布局事务。

let config = PTCollectionViewConfig()
config.scrollConfiguration = PTCollectionScrollConfiguration(
    style: .horizontalPaging,
    paging: PTCollectionPagingConfiguration(
        snapMode: .viewport,
        allowsSkippingPages: false
    )
)

let list = PTCollectionView(viewConfig: config)
list.onPageChanged = { context in
    print("page=\(context.page)/\(context.pageCount)")
}

样式和限制

交互和自动滚动

PTCollectionAutoScrollConfiguration 由 MainActor 协调器管理单一可取消任务。用户开始拖动时会暂停自动滚动;无减速的拖动在 didEndDragging 恢复,有减速的拖动在 didEndDecelerating 恢复。进入后台、离开窗口、骨架显示和 Reduce Motion 也会暂停。

分页列表如果不需要滚动条,可以通过配置关闭:

config.showsHorizontalScrollIndicator = false
config.showsVerticalScrollIndicator = false
list.setScrollIndicatorsHidden(true)

平台边界

这是 UIKit 列表实现,直接 UI 支持为 iOS 17+。滚动配置和身份模型属于 Core 值类型,可在 watchOS、visionOS 和 macOS 的对应宿主中复用;当前仓库没有把 UICollectionView 适配器宣称为这些平台的直接 UI 实现。

Español / English

PTCollectionScrollStyle defines main-axis behavior while PTCollectionViewType keeps layout geometry. The UIKit implementation targets iOS 17+ and Swift 6. The value contracts can be reused by watchOS, visionOS, and macOS adapters, but the current UICollectionView host remains iOS-only.

PTCollectionScrollStyle define el comportamiento del eje principal y PTCollectionViewType conserva la geometría. La implementación UIKit apunta a iOS 17+ y los contratos de valores pueden reutilizarse mediante adaptadores para watchOS, visionOS y macOS.