Iphone UITableViewCell奇数着色问题:

Iphone UITableViewCell奇数着色问题:,iphone,uitableview,Iphone,Uitableview,为什么这样做有效: - (void)tableView: (UITableView *)tableView willDisplayCell: (UITableViewCell *)cell forRowAtIndexPath: (NSIndexPath *)indexPath { cell.backgroundColor = [UIColor redColor]; } 但这不是吗 因此,我是否受限于预定义的UIColor颜色?您指定的值无效。颜色通道值是介于0.0f..1.0f范围内的

为什么这样做有效:

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


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

您指定的值无效。颜色通道值是介于
0.0f..1.0f

范围内的浮动。指定的值无效。颜色通道值是范围
0.0f..1.0f

内的浮动使用:

cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:100/255.0 blue:100/255.0 alpha:1];
它们需要浮动。

使用:

cell.backgroundColor = [UIColor colorWithRed:250/255.0 green:100/255.0 blue:100/255.0 alpha:1];
它们需要是浮动的。

谢谢:)是的,只需要像艾哈迈特所暗示的那样除以255即可谢谢:)是的,只要像艾哈迈特暗示的那样除以255就行了。:)