• Stars
    star
    209
  • Rank 182,226 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

AEXML

Swift minion for simple and lightweight XML parsing
Swift
990
star
2

AEIconizer

Sketch plugin for automatic scaling of iOS app icon artwork in all needed sizes
441
star
3

AEFlowchart

Sketch plugin for fast and convenient creation of flowcharts
378
star
4

xcode-project-renamer

Swift script for renaming Xcode project
Swift
353
star
5

AERecord

Super awesome Swift minion for Core Data (iOS, macOS, tvOS)
Swift
302
star
6

AEConsole

Customizable Console UI overlay with debug log on top of your iOS App
Swift
148
star
7

AEConicalGradient

Conical (angular) gradient for iOS written in Swift
Swift
83
star
8

TouchDemo

Demo from WWDC 2014 Session 235 - Advanced Scrollviews and Touch Handling Techniques
Swift
38
star
9

AELog

Simple, lightweight and flexible debug logging framework written in Swift
Swift
31
star
10

AEViewModel

Swift minion for convenient creation of tables and collection views
Swift
19
star
11

AEImage

Adaptive image viewer for iOS (with support for zoom, gyro motion and infinite scroll)
Swift
17
star
12

swift-greenfield

greenfield swift app project
Swift
12
star
13

AEAppVersion

Simple and Lightweight App Version Tracking for iOS written in Swift
Swift
12
star
14

AECoreDataUI

Super awesome Core Data driven UI for iOS written in Swift
Swift
11
star
15

AEDotFiles

From vanilla to personalized macOS in less than 30 minutes
Shell
11
star
16

bitrise-step-xcode-project-info

Bitrise step which extracts Xcode project information to environment variables
Shell
8
star
17

AETransition

Custom transitions for iOS - simple yet powerful
Swift
4
star
18

AESound

Convenience API for playing iOS system sounds
Swift
3
star
19

SwiftLook

Swift file viewer for iOS - it's like a QuickLook for Swift files
Swift
3
star
20

AECli

Swift package for making simple command line tools
Swift
3
star
21

AENetwork

Simple and lightweight networking in Swift
Swift
2
star
22

cs193p-matchismo

CS193p Winter 2013 - Matchismo - Card matching game
Objective-C
2
star
23

AECoreDataDemo

Demo project for AERecord and AECoreDataUI
Swift
2
star
24

swift-minions

Single-file helpers written in Swift, reusable across multiple projects
Swift
2
star
25

mappable

Swift package for simple and lightweight models mapping (with JSON support out of the box)
Swift
2
star
26

ae

command line personal assistant
Swift
1
star
27

AETool

Swift package for driving "ae" - command line personal assistant
Swift
1
star