Home > Back-end >  Change Parent Collection View cell background color when select child tableview?
Change Parent Collection View cell background color when select child tableview?

Time:08-29

I have the parent custom Collectionviewcell and inside I have the child custom Tableview. When I click table view I need to change the background color of collectionviewcell and tableview row background. I am trying achieve using gesture for tableview. but its not working.

CodePudding user response:

Why you don't use didSelect of tableView? Some code should be easy to see how you use gestures.

CodePudding user response:

try with protocols first your tableview inform the collection cell

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  backgroundColor = .red
  delegate?.didSelectItem(indexPath: indexPath)
}

then on your collectionView Cell

func didSelectItem(indexPath: IndexPath) {
  self.backgroundColor = .blue
}
  • Related