ios - how to change collection view cell background colour when it is selected? -
this code used if cell selected background colour have change in image view placed inside collection view cell. 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"]; }
now working removed if condition , tried using cellforitematindexpath .
cell = [collectionview cellforitematindexpath:indexpath]; cell.img_cell.backgroundcolor = [uicolor colorfromhexstring:@"#ffc400"]; // high
Comments
Post a Comment