ios - How to identify specific cell in UICollectionview -
i want set color black color cell1,cell4,cell7 ,...n & white color cell2,cell5,cell8 ,...n note: number of cell not fixed.
how can implement this??
i assume cellforitematindexpath
knows how cell number (i.e. 1
, 2
, 3
, 4
on picture) nsindexpath
passed method. can decide on color use obtaining remainder of division 3, this:
// decode index path cell number picture int cellnumber = [self getcellnumberfromindexpath:indexpath]; // figure out color if (cellnumber % 3 == 1) { // 1, 4, 7, etc ... // use black color } else if (cellnumber % 3 == 2) { // 2, 5, 8, etc ... // use white color }
Comments
Post a Comment