Reputation: 505
I have a custom tableview cell, if the cell is clicked then the cell should be expanded and if not clicked then the cell should not be expanded.
There is also a custom view and if the cell is clicked, I want the height of the custom view to be increased and if the cell is not clicked then it should be a certain height.Below this code is set in cellForRowAt
if TableView.rowHeight == 126 {
cell.CustomView = UIView(frame: CGRect(x: 7, y: 8, width: 359, height: 20))
return cell
}
else{
}
But the code I set to change the height of the view is not working and I am not sure where to go from there
When the cell is not clicked this is how my custom View looks like:
When the cell is clicked this is what the custom view looks like:
As you can see my problem is when the cell is not clicked, the bottom of the View is a straight line but when the cell is clicked, the bottom is rounded. I want the View to also be rounded when the cell is not clicked.
Upvotes: 0
Views: 87
Reputation: 6795
Add the code below . Hope this is gonna help you .
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//performSegue(withIdentifier: "toDetail", sender: self)
self.isExpanded = true
self.selectedIndex = indexPath
tableView.beginUpdates()
tableView.endUpdates()
self.isExpanded = false
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
self.selectedIndex = IndexPath()
tableView.beginUpdates()
tableView.endUpdates()
}
Courtesy : @Jože Ws
Upvotes: 1