After tapping on cell in particular section I want to change text color for title label in custom headerView.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch viewModel?.sections[indexPath.section].cellType {
case .selectionCell:
let cell = tableView.cellForRow(at: indexPath) as? CheckboxesTableViewCell
guard let checkboxOption = viewModel?.sections[indexPath.section].checkboxOptions?[indexPath.row] else { return }
checkboxOption.isSelected = !checkboxOption.isSelected
cell?.update(viewModel: checkboxOption)
// place where I should change text color for custom header
// let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: QuestionaryTableViewHeader
case .textCell:
debugPrint("Text field tapp")
case .none:
break
}
}
Any help...
You need to use headerView(forSection:
if let headerView = tableView.headerView(forSection:indexPath.section) as? QuestionaryTableViewHeader {
headerView.titleLabel.textColor = .red
}