aimalygin/StableCollectionViewLayout

GitHub: aimalygin/StableCollectionViewLayout

一个 Swift 库,用于在 iOS 的 UICollectionView 更新时自动调整内容偏移量,以保持视图稳定。

Stars: 70 | Forks: 6

Build Status Pods Version Platforms SPM Compatible

# 稳定的集合视图布局 此布局会在集合视图更新时调整内容偏移量。你可以插入、删除或重新加载项目,而 `StableCollectionViewLayout` 会自动处理内容偏移量。 就像这样 ![稳定效果](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/8e2b67d5c4203613.gif) ## 演示 ![演示](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/e95021dbf3203614.gif) ## 使用方法 你只需创建 `StableCollectionViewFlowLayout` 并将其传递给 `UICollectionView` 的初始化方法 ``` import StableCollectionViewLayout UICollectionView(frame: .zero, collectionViewLayout: StableCollectionViewFlowLayout()) ``` 此外,你也可以创建自己的 `StableCollectionViewLayout` 子类并使用它。 ## 安装说明 ### CocoaPods 包管理器 首选的安装方式是使用 [CocoaPods](https://cocoapods.org)。将以下内容添加到你的 `Podfile` 中: ``` pod 'StableCollectionViewLayout', '~> 1.0.3' ``` ### Carthage 依赖管理器 对于 [Carthage](https://github.com/Carthage/Carthage),将以下内容添加到你的 `Cartfile` 中: ``` github "aimalygin/StableCollectionViewLayout" ~> 1.0.3 ``` ### Swift 包管理器 对于 [Swift Package Manager](https://swift.org/package-manager/): ``` To integrate using Xcode: File -> Swift Packages -> Add Package Dependency Enter package URL: https://github.com/aimalygin/StableCollectionViewLayout, and select the latest release. ```
标签:Carthage, CocoaPods, iOS开发, iOS框架, Swift, Swift Package Manager, Swift库, UICollectionView, 内容偏移, 前端组件, 包管理器兼容, 布局管理, 布局调整, 库, 应急响应, 数据更新处理, 用户界面, 移动开发, 稳定性保证, 自动布局, 集合视图