Collapse and expand UICollectionView sections with one method call.
This library provides a custom
UICollectionViewthat allows to expand and collapse sections. Provides a simple API to manage collection view appearance.
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
import CampcotCollectionView
swift let campcotCollectionView = CampcotCollectionView()
campcotCollectionViewto view hierarchy.
Call
togglemethod on
campcotCollectionView.
swift public func toggle(to section: Int, offsetCorrection: CGFloat = default, animated: Bool, completion: ((Bool) -> Void)? = default)
Add UICollectionView to your Storyboard.
In
Identity Inspectorset the
Classproperty to
CampcotCollectionView.
Open
Attributes Inspectorand set the
Layoutproperty to
Custom. Set
Classproperty to either
ExpandedLayoutor
CollapsedLayout.
Create outlet for your collectionView.
Set datasource and delegate for collectionView.
Set the settings for collectionView in
Attributes Inspectoror manualy.
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
sectionto the top of view bounds.
offsetCorrection- the offset for pinned section from the top. Default value of
offsetCorrectionis
0.
animated- if
trueexpands 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
sectionto the top of view bounds.
offsetCorrection- the offset for pinned section from the top. Default value of
offsetCorrectionis
0.
animated- if
truecollapses 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
sectionto the top of view bounds.
offsetCorrection- the offset for pinned section from the top. Default value of
offsetCorrectionis
0.
animated- if
truetoggles sections with animation.
completion- callback for animation.
swift public func toggle(to section: Int, offsetCorrection: CGFloat = default, animated: Bool, completion: ((Bool) -> Void)? = default)