Need help with CampcotCollectionView?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

touchlane
159 Stars 7 Forks MIT License 97 Commits 1 Opened issues

Description

Collapse and expand UICollectionView sections with one method call.

Services available

!
?

Need anything else?

Contributors list

LOGO

Language Build Status codecov Version License Platform

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 '' do pod 'CampcotCollectionView' end

Then, run the following command:

$ pod install

Usage

Manual Setup

import CampcotCollectionView
  1. Create CollectionView
    swift
    let campcotCollectionView = CampcotCollectionView()
    
  2. Add
    campcotCollectionView
    to view hierarchy.
  3. Call

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

    Storyboard Setup

  4. Add UICollectionView to your Storyboard.

  5. In

    Identity Inspector
    set the
    Class
    property to
    CampcotCollectionView
    .
  6. Open

    Attributes Inspector
    and set the
    Layout
    property to
    Custom
    . Set
    Class
    property to either
    ExpandedLayout
    or
    CollapsedLayout
    .
  7. Create outlet for your collectionView.

  8. Set datasource and delegate for collectionView.

  9. Set the settings for collectionView in

    Attributes Inspector
    or manualy.

Documentation

CampcotCollectionView

A Boolean value that determines whether the sections are expanded.

swift
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
0
.
animated
- if
true
expands sections with animation.
completion
- callback for animation.
swift
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
0
.
animated
- if
true
collapses sections with animation.
completion
- callback for animation.
swift
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
0
.
animated
- if
true
toggles sections with animation.
completion
- callback for animation.
swift
public func toggle(to section: Int,
                   offsetCorrection: CGFloat = default,
                   animated: Bool,
                   completion: ((Bool) -> Void)? = default)

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.