CampcotCollectionView
  • October 10, 2023

This library provides a custom UICollectionView that allows to expand and collapse sections. Provides a simple API to manage collection view appearance.

CampcotCollectionView

Requirements


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

Installation


CocoaPods


CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate CampcotCollectionView into your Xcode project using CocoaPods, specify it in your Podfile:

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

target ‘<Your Target Name>’ do
pod ‘CampcotCollectionView’
end

Then, run the following command:

$ pod install

Usage


Manual Setup

import CampcotCollectionView

  1. Create CollectionView

let campcotCollectionView = CampcotCollectionView()

  1. Add campcotCollectionView to view hierarchy.
  2. Call toggle method on campcotCollectionView.

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

Storyboard Setup

  1. Add UICollectionView to your Storyboard.
  2. In Identity Inspector set the Class property to CampcotCollectionView.
  3. Open Attributes Inspector and set the Layout property to Custom. Set Class property to either ExpandedLayout or CollapsedLayout.
  4. Create outlet for your collectionView.
  5. Set datasource and delegate for collectionView.
  6. Set the settings for collectionView in Attributes Inspector or manualy.

Documentation


CampcotCollectionView

A Boolean value that determines whether the sections are expanded.

public var isExpanded: Bool { get }

Expands all the sections. Pins a section at index section to the top of view bounds. offsetCorrection – the offset for pinned section from the top. Default value of offsetCorrection is 0animated – if true expands sections with animation. completion – callback for animation.

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

Collapses all the sections. Pins a section at index section to the top of view bounds. offsetCorrection – the offset for pinned section from the top. Default value of offsetCorrection is 0animated – if true collapses sections with animation. completion – callback for animation.

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

Toggles current state from collapsed to expaned and vise versa. Pins a section at index section to the top of view bounds. offsetCorrection – the offset for pinned section from the top. Default value of offsetCorrection is 0animated – if true toggles sections with animation. completion – callback for animation.

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

GitHub


View Github

#awesome #cocoapods #collapsible #expandable #ios #library #swift #uicollectionview
YOU MIGHT ALSO LIKE...
DeckKit

DeckKit is a SwiftUI library that makes it easy to create deck-based apps. It has a DeckView that can render any list ...

SwiftUICam

If you want to have a custom camera using SwiftUI and not using the UIPickerController that will display the original ...

CameraView for SwiftUI 📷

CameraView allows you to have a SnapChat-style screen on your SwiftUI app that gives a realtime view of the iPhone ...

Camera-SwiftUI

SwiftUI has proven to be a really awesome new framework to build and design apps in a quick and reliable ...