ios - how to set different color for tableview cell -
how can set different color multiple rows in tableview, maybe 10 different colors. figured part alternative row colors.
//alternate row colour if (indexpath.row % 2) { cell.contentview.backgroundcolor = [[uicolor alloc]initwithred:87.0/255.0 green:84.0/255.0 blue:229.0/255.0 alpha:1]; } else { cell.contentview.backgroundcolor = [[uicolor alloc]initwithred:187.0/255.0 green:184.0/255.0 blue:229.0/255.0 alpha:1]; }
int frequency = indexpath.row %10; switch (frequency) { case 0: //color 1 break; case 1: //color 2 break; case 2: //color 3 break; case 3: //color 4 break; //up case 9 default: break; }
alternatively, set array of color objects somewhere , phone call colors[frequency]. same number of code lines, not messy
ios objective-c uitableview ios7.1
No comments:
Post a Comment