views:

19

answers:

2

Why does this work:

- (void)tableView: (UITableView *)tableView willDisplayCell: (UITableViewCell *)cell forRowAtIndexPath: (NSIndexPath *)indexPath {
    cell.backgroundColor = [UIColor redColor];
}

but this doesn't?

- (void)tableView: (UITableView *)tableView willDisplayCell: (UITableViewCell *)cell forRowAtIndexPath: (NSIndexPath *)indexPath {
    cell.backgroundColor = [UIColor colorWithRed:250 green:100 blue:100 alpha:1];
}

Am I thus constrained to the pre-defined UIColor colours?

+2  A: 

The values you specify are invalid. Color channel values are floats in the range 0.0f..1.0f.

Ole Begemann
thanks :) yeah, just need to divide by 255 then as ahmet implies. :)
Thomas Clayson
+2  A: 

use:

cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:100/255.0 blue:100/255.0 alpha:1];

They need to be float.

ahmet emrah
they need to be divided by 255. :) thank you.
Thomas Clayson