Reputation: 143
This code is I used if cell is selected then the background colour have to change in image view it is placed inside the collection view cell. But its not working
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (cell.selected) {
cell.img_cell.backgroundColor = [UIColor colorFromHexString:@"#ffc400"]; // highlight selection
}
else
{
cell.backgroundColor = [UIColor clearColor]; // Default color
}
NSLog(@"Selected section>> %@",[arr_images objectAtIndex:indexPath.row]);
// cell.backgroundColor=[UIColor colorFromHexString:@"#ffc400"];
}
Upvotes: 1
Views: 2293
Reputation: 143
now its working i removed the if condition and tried using cellForItemAtIndexPath .
cell = [collectionView cellForItemAtIndexPath:indexPath];
cell.img_cell.backgroundColor = [UIColor colorFromHexString:@"#ffc400"]; // high
Upvotes: 2