forum

Home / DeveloperSection / Forums / How to change the background color of UICollectionView cell in iOS?

How to change the background color of UICollectionView cell in iOS?

Anonymous User 4934 23-Dec-2015

I have created an application using UICollectionView, and adding some images into the collection view cell.
Now I want to change the cell background color whenever the element is tapped.
I have tried by this code:

-(void) collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
    //change color when tapped
}

-(void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath{
    //change back on touch up
}

It works but it will change only when I keep my finger for a bit longer time.
Can you tell me is there any functionality similar like in UITableViewCell willSelectItemAtIndexPath: method.
Please suggest me any solution.


Updated on 23-Dec-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By