CampcotCollectionView version 0.0.7

CampcotCollectionView version 0.0.7

由以下开发者维护:Evgeny DedovetsPavel Kondrashkov



CampcotCollectionView version 0.0.7

  • Touchlane LLC

LOGO

Language Build Status codecov Version License Platform

本库提供了一个自定义的 UICollectionView,允许展开和折叠部分。提供了一套简单的 API 来管理集合视图的外观。

CampcotCollectionView

要求

  • iOS 9.0+
  • Xcode 10.2+
  • Swift 5.0+

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。您可以用以下命令安装它:$ gem install cocoapods

$ gem install cocoapods

要使用 CocoaPods 将 CampcotCollectionView 集成到您的 Xcode 项目中,在您的 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'CampcotCollectionView'
end

然后,运行以下命令:

$ pod install

用法

手动设置

import CampcotCollectionView
  1. 创建 CollectionView
let campcotCollectionView = CampcotCollectionView()
  1. campcotCollectionView 添加到视图层级。
  2. campcotCollectionView 上调用 toggle 方法。
public func toggle(to section: Int,
                   offsetCorrection: CGFloat = default,
                   animated: Bool,
                   completion: ((Bool) -> Void)? = default)

Storyboard 设置

  1. 将 UICollectionView 添加到您的 Storyboard 中。
  2. Identity Inspector 中将 Class 属性设置为 CampcotCollectionView
  3. 打开 Attributes Inspector 并将 Layout 属性设置为 Custom。将 Class 属性设置为 ExpandedLayoutCollapsedLayout
  4. 为您的一个 collectionView 创建 outlet。
  5. 为 collectionView 设置数据源和代理。
  6. Attributes Inspector 中设置 collectionView 的设置,或手动设置。

文档

CampcotCollectionView

一个布尔值,用于确定是否展开部分。

public var isExpanded: Bool { get }

展开所有部分。将索引为 section 的部分固定到视图边界顶部。 offsetCorrection - 从顶部对固定部分的偏移。默认值 `offsetCorrection` 为 `0`。 animated - 如果 `true`,则使用动画展开部分。 completion - 动画完成的回调。

public func expand(from section: Int,
                   offsetCorrection: CGFloat = default,
                   animated: Bool,
                   completion: ((Bool) -> Void)? = default)

折叠所有部分。将索引为 section 的部分固定到视图边界顶部。 offsetCorrection - 从顶部对固定部分的偏移。默认值 `offsetCorrection` 为 `0`。 animated - 如果 `true`,则使用动画折叠部分。 completion - 动画完成的回调。

public func collapse(to section: Int,
                     offsetCorrection: CGFloat = default,
                     animated: Bool,
                     completion: ((Bool) -> Void)? = default)

在折叠和展开状态之间切换当前状态。将索引为 section 的部分固定到视图边界顶部。 offsetCorrection - 从顶部对固定部分的偏移。默认值 `offsetCorrection` 为 `0`。 animated - 如果 `true`,则使用动画切换部分。 completion - 动画完成的回调。

public func toggle(to section: Int,
                   offsetCorrection: CGFloat = default,
                   animated: Bool,
                   completion: ((Bool) -> Void)? = default)