https://github.com/kharauzov/collapsetableview
Easily collapse or expand tableView's sections.
https://github.com/kharauzov/collapsetableview
collapse expandabletableview ios swift uitableview uitableview-section uitableviewcell
Last synced: 10 months ago
JSON representation
Easily collapse or expand tableView's sections.
- Host: GitHub
- URL: https://github.com/kharauzov/collapsetableview
- Owner: Kharauzov
- License: mit
- Created: 2019-06-08T08:46:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-01T05:04:58.000Z (almost 6 years ago)
- Last Synced: 2025-01-02T00:01:30.621Z (over 1 year ago)
- Topics: collapse, expandabletableview, ios, swift, uitableview, uitableview-section, uitableviewcell
- Language: Swift
- Homepage:
- Size: 2.34 MB
- Stars: 18
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


[](https://doge.mit-license.org)
## Overview
This is a Swift version of [STCollapseTableView](https://github.com/iSofTom/STCollapseTableView) that was written in Objective-C.
CollapseTableView enables you to make expandable UITableView's sections with just a few lines of code.
## Presentation
## Installation
### CocoaPods
```ruby
pod 'CollapseTableView'
```
### Manually
Just copy **Source** folder to your Xcode project.
## How To
After adding the framework to your project, you need to import the module
```swift
import CollapseTableView
```
Then you need to subclass your *UITableView* with *CollapseTableView* and set delegate/datasource as you always do.
By default, tableView sections are clickable and expandable.
If you want to disable clickability of sections, there is a special property for this:
```swift
public var shouldHandleHeadersTap: Bool
```
So after you implement standard tableView's dataSource/delegate methods for sections, you will be able to open or close the sections with your cells by clicking them.
There're extra tableView methods for work with sections:
```swift
public func toggleSection(_ sectionIndex: Int, animated: Bool)
public func openSection(_ sectionIndex: Int, animated: Bool)
public func closeSection(_ sectionIndex: Int, animated: Bool)
public func isOpenSection(_ sectionIndex: Int) -> Bool
```
There's a closure to observe events for opening/closing sections:
```swift
tableView.didTapSectionHeaderView = { (sectionIndex, isOpen) in
}
```
## Features
- [ ] Exlusive sections mode (Max 1 opened section)
## Feedback
If you have any questions or suggestions, feel free to open issue just at this project.
## License
CollapseTableView and all its classes are available under the MIT license. See the LICENSE file for more info.