Skip to content

A simple example of using UIStackView to expand and collapse variable sized UITableViewCells with auto layout.

License

Notifications You must be signed in to change notification settings

NormanBitSolace/ExpandableCells

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expand and collapse UITableViewCells with UIStackView

This project demonstrates expanding and collapsing UITableView cells. There are many approaches to this but using a UIStackView is currently (Xcode 10, Swift 5) the one that best handles cells with unique heights and supports auto layout. There are so many details to get right that I collected them in this simple project, rather than searching Stack Overflow each time I implement. Details like pinning the UIStackView to the cell’s contentView , setting tableView.rowHeight = UITableView.automaticDimension, setting variable line height UILabels Content Compression Resistance Priority, etc. are easy to overlook and may not manifest issues till runtime.

expandingCellsAnimation

About

A simple example of using UIStackView to expand and collapse variable sized UITableViewCells with auto layout.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages