I have a UIViewController which has a UITableView and a button called "A" . This table has sections and rows. Now in my scenario i want to highlight a section when "A" clicked. I don't want to do this work in viewForHeaderInSection as i don't want to reload the whole table view. The code that i am trying at the moment on button click is as follows,
public func scrollToSection(sectionNumber:Int)
{
let indexPath = NSIndexPath(forRow: 0, inSection: sectionNumber)
let headerView = tableView.headerViewForSection(indexPath.section)
tableView.beginUpdates()
headerView?.contentView.backgroundColor = UIColor.cyanColor()
tableView.endUpdates()
tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Middle, animated: true)
}
but somehow it is not showing the cyan color on button click. Can anyone please post a proper solution in swift?