Arthur
Arthur

Reputation: 1760

how to set different colors for different cells

How to set different colors to different calls? For example all cells with predicate "a" have red color, with predicate "b" - yellow, etc

Upvotes: 0

Views: 134

Answers (1)

James Webster
James Webster

Reputation: 32066

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CELL"];

if (predicateA)
{
    [cell setBackgroundColor:[UIColor redColor]];
}
if (predicateB)
{
    [cell setBackgroundColor:[UIColor yellowColor]];
}

You can describe this colouring with the following truth table:

|    A     |     B    |    Color    |
-------------------------------------
|    1     |     1    |     YEL     |    <- What do you want here?
|    1     |     0    |     RED     |
|    0     |     1    |     YEL     |
|    0     |     0    |    UNDEF    |

However, I'm getting a little confused about what you want with the 1, 1 case

Upvotes: 1

Related Questions