A UICollectionView
subclass that enables you to easily expand and collapse sections.
- Manually clone this repository to your machine or add it as a Git submodule to your project.
- Drag the folder
NExpandableCollectionView
into your Xcode project to add all the files in it to your project.
#import "NExpandableCollectionView.h"
- Create an
NExpandableCollectionView
instead of a regularUICollectionView
. - Set
allowsMultipleExpandedSections
Boolean to enable/disable expanding more than one section at a time, default isNO
. - Call
(void) toggleSection:(NSInteger)section;
on the collection view. This will collapse the section if expanded (And collapse any other sections ifallowsMultipleExpandedSections = NO
), otherwise, expand it. - You check if a section is expanded or not using
(BOOL) isExpandedSection:(NSInteger)section;
NExpandableCollectionView
conforms to NExpandableCollectionViewDelegate
that notifies you about the various states the expanding/collapsing items go through. You can use this delegate to apply other animations alongside the expand/collapse animations.
Please check the documentation for more informations about this.
In the example, toggling the sections is done by clicking on the section header.