2010-10-21 121 views
0

为什么这个工作:的UITableViewCell古怪的着色问题:

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

不?

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

我是否受限于预定义的UIColor颜色?

回答

3

使用:

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

他们需要的是浮动。

+0

他们需要除以255. :)谢谢。 – 2010-10-21 13:34:40

2

您指定的值无效。颜色通道值浮在范围0.0f..1.0f

+0

谢谢:)是的,只需要除以255然后像ahmet暗示的那样。 :) – 2010-10-21 13:35:17