How to get Header of collection view on DidSelectItemAtIndexPath for change text of header while select item.
How to get header of collection view in swift?
6.6k views Asked by Rajput Nancy Katal At
2
There are 2 answers
8
On
You can use:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
let indexHeaderForSection = NSIndexPath(row: 0, section: indexPath.section) // Get the indexPath of your header for your selected cell
let header = collectionView.viewForSupplementaryElementOfKind(indexHeaderForSection)
}
As of iOS 9, you can use:
to get a supplementary view by index path.
Check out Apple's documentation