AEAccordion

Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)

  • 所有者: tadija/AEAccordion
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Swift 4.2
Platforms iOS
CocoaPods
Carthage
Swift Package Manager
License MIT

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

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 override setExpanded: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 on expandedIndexPaths.
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
    }
    
}

For more details check out Sources and Example.

Installation

License

This code is released under the MIT license. See LICENSE for details.

主要指标

概览
名称与所有者tadija/AEAccordion
主编程语言Swift
编程语言Swift (语言数: 3)
平台
许可证MIT License
所有者活动
创建于2015-06-27 01:41:08
推送于2018-09-18 22:24:38
最后一次提交2018-09-19 00:24:03
发布数10
最新版本名称2.1.1 (发布于 )
第一版名称AEAccordion-v1.0.2 (发布于 2015-07-15 23:35:20)
用户参与
星数210
关注者数10
派生数24
提交数61
已启用问题?
问题数12
打开的问题数3
拉请求数0
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?