Answering a question on SO
Swift
Latest commit 46533c9 Dec 15, 2015 @rayfix Update README.md
Permalink
Failed to load latest commit information.
MultilineDemo.xcodeproj
MultilineDemo
.gitignore
LICENSE
README.md
demo.gif

README.md

MultilineDemo

This projects demostrates how you can have a multiple line UILabel collapse and expand within a UITableView. It uses dynamic cell sizing and autolayout. In did select row at index path the key code is below. It triggers a table view animation and simply toggles the number of lines between 0 and 1 or 1 and 0. (When you sent numberOfLines to 0 it is a special value that means "any number of lines."

        tableView.beginUpdates()
        label.numberOfLines = label.numberOfLines == 0 ? 1 : 0
        tableView.endUpdates()

I am including the whole project here because there are many small mistakes you can make so that this doesn't work. (Many newer developers fall back to computing font metrics manually, or hard coded numbers because they assume it can't be done.)

demo