Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tadija/AEAccordion
Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)
https://github.com/tadija/AEAccordion
Last synced: 5 days ago
JSON representation
Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)
- Host: GitHub
- URL: https://github.com/tadija/AEAccordion
- Owner: tadija
- License: mit
- Created: 2015-06-27T01:41:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T22:24:38.000Z (about 6 years ago)
- Last Synced: 2024-11-30T17:38:06.553Z (12 days ago)
- Language: Swift
- Homepage:
- Size: 391 KB
- Stars: 211
- Watchers: 11
- Forks: 24
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - AEAccordion - UITableViewController with accordion effect (expand / collapse cells). (UI / Table View / Collection View)
- awesome-ios-star - AEAccordion - UITableViewController with accordion effect (expand / collapse cells). (UI / Table View / Collection View)
- awesome-swift-cn - AEAccordion - UITableViewController with accordion effect (expand / collapse cells). (Libs / UI)
README
[![Swift 4.2](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](https://swift.org)
[![Platforms iOS](https://img.shields.io/badge/Platforms-iOS%20-lightgray.svg?style=flat)](http://www.apple.com)
[![CocoaPods](https://img.shields.io/cocoapods/v/AEAccordion.svg?style=flat)](https://cocoapods.org/pods/AEAccordion)
[![Carthage](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
[![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg?style=flat)](LICENSE)# AEAccordion
**UITableViewController with accordion effect (expand / collapse cells)**> Simple and lightweight solution for making accordion effect in table view controller. Show detailed content on demand.
![AEAccordion](http://tadija.net/public/AEAccordion.gif)
## Index
- [Features](#features)
- [Usage](#usage)
- [Installation](#installation)
- [License](#license)## 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 override `setExpanded:animated:`.
```swift
import AEAccordionfinal 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 on `expandedIndexPaths`.
```swift
import AEAccordionfinal 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
}
}
```> For more details check out [Sources](Sources) and [Example](Example).
## Installation
- [Swift Package Manager](https://swift.org/package-manager/):
```
.Package(url: "https://github.com/tadija/AEAccordion.git", majorVersion: 2)
```- [Carthage](https://github.com/Carthage/Carthage):
```ogdl
github "tadija/AEAccordion"
```- [CocoaPods](http://cocoapods.org/):
```ruby
pod 'AEAccordion'
```## License
This code is released under the MIT license. See [LICENSE](LICENSE) for details.