ARAccordionTableView
Example
Requirements
- iOS 9.0
- Xcode 11.2
- Swift 5
Installation
ARAccordionTableView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ARAccordionTableView'Then, run the following command:
pod installHow To Use?
Steps:
You can use ARAccordionTableView in simple three easy steps.
- Add pod in your PodFile.
- Change your
UITableViewclass withARAccordionTableView - Subclass your
UITableViewHeaderFooterViewwithARAccordionTableViewHeaderView
Different Configuration:
- Open one section at any time, to achive this set following property like below.
tableView.allowMultipleSectionsOpen = falseand if you want to open multiple sections set value to true
tableView.allowMultipleSectionsOpen = true- Set
keepOneSectionOpenproperty totrueto keep one section open all the time
tableView.keepOneSectionOpen = true- Open specific sections on start like below.
tableView.initialOpenSections = [1,3]- To check if section is open or close
let isSection = tableView.isSectionOpen(1)- To toggle section use following function
tableView.toggleSection(1)- To close all sections
tableView.closeAllSections()ARAccordionTableViewDelegate:
extension ViewController : ARAccordionTableViewDelegate {
func tableView(_ tableView: ARAccordionTableView, canInteractWithHeaderAtSection section: Int) -> Bool {
//Return whether user can interact with header View
return true
}
func tableView(_ tableView: ARAccordionTableView, willOpenSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called before section is opening
}
func tableView(_ tableView: ARAccordionTableView, didOpenSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called after section opened
}
func tableView(_ tableView: ARAccordionTableView, willCloseSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called before section closes
}
func tableView(_ tableView: ARAccordionTableView, didCloseSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called after section closed
}
func tableView(_ tableView: ARAccordionTableView, didLogPressedSection section: Int, withHeader header: UITableViewHeaderFooterView?, longPressGestureState state: UIGestureRecognizer.State) {
// called when user long press on a tableView header
}
}Author
AbdulRehman Warraich, [email protected]
ARAccordionTableView is based on FZAccordionTableView.
License
ARAccordionTableView is released under the MIT license. See LICENSE for details.

