Last active
July 20, 2016 02:29
-
-
Save MainasuK/f8d00d1a7601a207dd1cd2458362ba0e to your computer and use it in GitHub Desktop.
iOS Tips: Change table view cell row height
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
// If you use self-size cell with stack view or Auto Layout. | |
// Try this to change row height with animation | |
// Assume you set the content heightConstraint which group in your stack view | |
// Or other heightConstraint to make your cell self-size | |
func changeRowHeight(in tableView: UITableView, at indexPath: IndexPath, with height: CGFloat) { | |
tableView.beginUpdates() | |
// Change your cell heightConstraint height | |
// Should not call tableView.reloadData otherwise do animation by yourself | |
// For example: | |
let cell = tableView.cellForRow(at: indexPath) as! YourTableViewCell | |
cell.heightConstraint.constant = 100 | |
tableView.endUpdates() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment