Created
September 23, 2017 19:38
-
-
Save RNHTTR/417f92e628ef6b300742dd8af94b206f to your computer and use it in GitHub Desktop.
Example of how to use tableView(_:heightForRowAt:) to adjust the height of a UITableViewCell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The table views in this app actually don't make use of tableView(_:heightForRowAt:). These table views set the table views' | |
// rowHeight and estimatedRowHeight properties to UITableViewAutomaticDimension and 110, respectively, and they make use | |
// of a series of constraints to automatically set each cells' row height. | |
// Use tableView(_:heightForRowAt:) to set the height for specific table view cells. | |
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
// Set the row height for the first (zeroth) cell in all section(s) to 100, and set all other cells to 50. | |
// You can also set the row height for all cells in a section by accessing indexPath.section. | |
if indexPath.row == 0 { | |
return 100 | |
} | |
return 50 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment