How to expand and shrink my ViewControllerCell?

43 Views Asked by At

So i have this custom view cell, i want to expand it twice his height without his content getting adjust

this is what i was trying to do

import Foundation
import UIKit
import SnapKit

class ViewControllerCell: UITableViewCell {
    
   // here I declare my labels, stackview and the constraints
       
    
    func toggleExpansion() {
        isExpanded = !isExpanded
        
        if isExpanded {
            print ("Expanded")
         
        } else {
            print ("Contract")
          
        }
    }
}

and this method is getting call on my ViewController

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        guard let cell = tableView.cellForRow(at: indexPath) as? ViewControllerCell else {
            return
        }
        
        cell.toggleExpansion()
        
        tableView.deselectRow(at: indexPath, animated: true)
    }

When the cell is enlarged, the lower cells should stay below

What should i do

0

There are 0 best solutions below