it’s a hard to explain issue so i hope i can state it
i have a tableview and i want that..
row number 1 have a background and row number 2 have another background .
and row number 3 have a third background..
the fourth row should have the first background and the fifth should have the second ..
and so forth ..
i used this code
if(row+1%1==0){
bg = [UIImage imageNamed:@"row1.png"];
selectionBg = [UIImage imageNamed:@"row1.png"];
}
else if(row+1%2==0){
bg = [UIImage imageNamed:@"row2.png"];
selectionBg = [UIImage imageNamed:@"row2.png"];
}else if(row+1%3==0){
bg = [UIImage imageNamed:@"row3.png"];
selectionBg = [UIImage imageNamed:@"row3.png"];
}
i’m trying to use modulus but i get lost .. so is there a way for that?
thanks in advance
You should use
mod 3because you have three options:By the way, do you understand what a modulo operation does? This might be interesting to read (from Wikipedia):
This is what happens in the code: