Latest | 2.1.1 |
---|---|
Homepage | https://github.com/tadija/AEAccordion |
License | MIT |
Platforms | ios 9.0 |
Authors |
UITableViewController with accordion effect (expand / collapse cells)
Simple and lightweight solution for making accordion effect in table view controller. Show detailed content on demand.
Index
Features
- Create accordion effect in table view controller with less effort
- Animate expansion / collapsing of cells as you want (optional)
- Automatic scroll on cell expansion to make entire cell visible (optional)
Usage
- Subclass
AccordionTableViewCell
and overridesetExpanded:animated:
.
import AEAccordion
final class ReadmeTableViewCell: AccordionTableViewCell {
static let reuseIdentifier = "ReadmeTableViewCell"
@IBOutlet weak var headerView: HeaderView!
@IBOutlet weak var detailView: DetailView!
// MARK: Override
override func setExpanded(_ expanded: Bool, animated: Bool) {
super.setExpanded(expanded, animated: animated)
if animated {
UIView.transition(with: detailView, duration: 0.3, animations: {
self.detailView.isHidden = !expanded
}, completion: nil)
} else {
detailView.isHidden = !expanded
}
}
}
- Subclass
AccordionTableViewController
and configure cell height based onexpandedIndexPaths
.
import AEAccordion
final class ReadmeTableViewController: AccordionTableViewController {
override func viewDidLoad() {
super.viewDidLoad()
expandFirstCell()
}
func expandFirstCell() {
let firstCellIndexPath = IndexPath(row: 0, section: 0)
expandedIndexPaths.append(firstCellIndexPath)
}
// MARK: UITableViewDelegate
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return expandedIndexPaths.contains(indexPath) ? 200.0 : 50.0
}
}
Installation
-
.Package(url: "https://github.com/tadija/AEAccordion.git", majorVersion: 2)
-
github "tadija/AEAccordion"
-
pod 'AEAccordion'
License
This code is released under the MIT license. See LICENSE for details.
Latest podspec
{ "name": "AEAccordion", "version": "2.1.1", "license": { "type": "MIT", "file": "LICENSE" }, "summary": "UITableViewController with accordion effect (expand / collapse cells)", "source": { "git": "https://github.com/tadija/AEAccordion.git", "tag": "2.1.1" }, "source_files": "Sources/AEAccordion/*.swift", "swift_version": "4.2", "platforms": { "ios": "9.0" }, "homepage": "https://github.com/tadija/AEAccordion", "authors": { "tadija": "[email protected]" }, "social_media_url": "http://twitter.com/tadija" }
Wed, 19 Sep 2018 11:40:22 +0000