Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change sections title color in didSelectRow

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…

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to use headerView(forSection:

if let headerView = tableView.headerView(forSection:indexPath.section) as? QuestionaryTableViewHeader {
   headerView.titleLabel.textColor = .red  
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading