Change Static Table View Cell Height

I have an if statement in my app where I want it to change the height of a static tableview cell. Here's what I'm hoping for

if my if statement {

changeCell.height = 313

} else {

changeCell.height = 0

}

The cell is changeCell. I know that the bolded section is not valid code. That's what I'm asking for help with. Thanks!

Replies

If you want to change all the cells height :


func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 100.0 / /the row height you want
}

You can do it for specific cell as well


func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            var height: CGFloat 
            if indexPath.row == 10 {
                height = 100
            } else {
                height = 80
            }
            return height
        }