Skip to content

Guide · Open source

How to use folding-cell: install and build an expanding iOS cell

Updated · written with AI from the project's own documentation and checked against our catalogue data

folding-cell is an open-source Swift library for iOS that gives a table view cell an expanding, folding-paper animation. A compact summary opens into a detailed view when the user taps it. This guide walks through installing the library, building the cell in a storyboard or nib, and wiring up the table view code so the cell opens and closes.

FoldingCellRamotion/folding-cell · ★ 10.2k · MIT

Quick start

  1. 1Check requirements. Confirm your project uses Xcode 10.2 or later and an iOS 8.0+ deployment target, as the README states.
  2. 2Install the library. Add the pod 'FoldingCell' line to your Podfile, or add the Swift Package Manager dependency to Package.swift, or drag FoldingCell.swift into your project.
  3. 3Create the cell class. Make a new class that inherits from FoldingCell.
  4. 4Add the foreground and container views. In your storyboard or nib, add a RotatedView for the closed state and a second view for the open state, then connect the outlets and top constraints.
  5. 5Set itemCount. Set itemCount to the number of folds, 2 or greater, in the storyboard or in code.
  6. 6Add the table view code. Store row heights, override heightForRowAtIndexPath, and toggle the cell in didSelectRowAtIndexPath with an animated table update.

What folding-cell does and who it is for

folding-cell is an expanding content cell with an animation inspired by folding paper card material design. You show a compact summary in a table view, and tapping the cell unfolds it to reveal more content.

It is written in Swift for iOS apps. It suits iOS developers building list screens with expandable items who want a ready-made animation instead of writing their own. It is not a no-code tool, and it does not target Android or the web.

Check the requirements before you install

The README lists two requirements: Xcode 10.2 and an iOS 8.0+ target. Check these against your project before you start.

The README's code samples use older Swift syntax, such as tableView(tableView:heightForRowAtIndexPath:) with NSIndexPath. Expect to adapt them to the Swift version your project uses.

  • Xcode 10.2 (per README)
  • iOS 8.0+ deployment target (per README)

Install folding-cell with CocoaPods, Swift Package Manager or by hand

The README offers several routes. For CocoaPods, add the pod to your Podfile. For Swift Package Manager, add the package dependency to Package.swift. You can also drag the FoldingCell.swift file into your project directly.

The README also mentions Carthage, but its instructions name Mantle in the Cartfile step; check that line against the library you actually want before relying on it.

  • CocoaPods: add the pod to your Podfile, then install it as you normally would.
  • Swift Package Manager: add the dependency to Package.swift.
  • Manual: drag FoldingCell.swift into your Xcode project.
pod 'FoldingCell' dependencies: [ .package(url: "https://github.com/Ramotion/folding-cell.git", from: "5.0.2") ]

Build the cell in your storyboard or nib

Create a new cell class that inherits from FoldingCell. In your storyboard or nib, add a UIView that inherits from RotatedView and connect it to the foregroundView outlet. Add constraints from this view to the superview and connect the top constraint to foregroundViewTop. This view is shown when the cell is closed.

Add the other views to the cell, connect them to containerView, and set constraints to the superview. Connect the top constraint to containerViewTop. This view is shown when the cell is opened.

Set the itemCount property, which is the number of folds. The README says the range is 2 or greater and the default is 2. You can set it in the storyboard because it is marked IBInspectable.

  • foregroundView: the closed state view, connected to a RotatedView
  • foregroundViewTop: the top constraint of foregroundView
  • containerView: the open state view
  • containerViewTop: the top constraint of containerView
  • itemCount: number of folds, minimum 2

Wire up the table view controller

Define two constants for the closed and open cell heights. Each must be equal to or greater than the matching view's height. Keep an array of cell heights, one per row, starting with the closed height.

Override heightForRowAtIndexPath so it returns the height for each row. In didSelectRowAtIndexPath, call unfold on the tapped cell, update its stored height, and run tableView.beginUpdates and endUpdates inside a UIView animation so the table resizes.

Finally, in willDisplayCell, set each cell's state with selectedAnimation so reused cells show the correct open or closed position.

fileprivate struct C { struct CellHeight { static let close: CGFloat = *** // equal or greater foregroundView height static let open: CGFloat = *** // equal or greater containerView height } }

Set the fold animation timing

The cell class can override animationDuration to set timing for each fold. The README sample uses an array with one duration per fold, and notes that the count should equal itemCount. The sample durations are 0.33, 0.26 and 0.26 seconds.

The README sample also uses 0.5 seconds for opening and 0.8 seconds for closing the cell in the table view controller. You can change these values to suit your design.

override func animationDuration(itemIndex:NSInteger, type:AnimationType)-> NSTimeInterval { // durations count equal it itemCount let durations = [0.33, 0.26, 0.26] // timing animation for each view return durations[itemIndex] }

What people use it for

  • A shopping or order list where each row shows a summary and expands to show details.
  • A settings or FAQ screen where each item folds open to reveal its explanation.
  • A product catalogue in an iOS app where tapping a card shows specs, pricing or options.
  • A message or ticket list where the closed cell shows a subject line and the open cell shows the full text.

Frequently asked questions

Is folding-cell free to use?

folding-cell is released under the MIT license, as stated in the README. The README asks that you credit and backlink to https://www.ramotion.com/ if you use it in your project.

Does folding-cell work on Android?

No. It is an iOS-only Swift library. The README points to a separate Android project, folding-cell-android, under the same Ramotion organisation.

What do I need to install folding-cell?

The README lists Xcode 10.2 and an iOS 8.0+ target. You can install it with CocoaPods, Swift Package Manager, or by adding FoldingCell.swift to your project.

Can I use folding-cell without a storyboard?

Yes. The README says you can create foregroundView and containerView from code, and links to an example project that does this.

Why does my cell not resize when I tap it?

The README's method depends on updating the stored row height and calling beginUpdates and endUpdates inside the animation. Check that heightForRowAtIndexPath returns the value you stored, and that each open height is equal to or greater than the containerView height.

How does folding-cell compare with other expandable cell libraries?

The source does not compare it with specific alternatives. Other iOS expandable table view cell libraries exist, so compare them on the README requirements, Swift version support and how actively they are maintained.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use folding-cell if you build an iOS app with list screens and want a ready-made folding animation without writing your own. Pick something else if you need Android or web support, a no-code tool, or a setup that matches current Swift and Xcode versions, since the README's samples are dated.

Install options & downloads