我正在尝试使用以下代码更改单元格的颜色,但是它将所有单元格显示为白色字体,而不是我拥有的黄金rgb颜色代码。
if (row == 0)
cell.detailTextLabel.text=@"An blah blah";
cell.textLabel.textColor = [UIColor colorWithRed:139 green:136 blue:120 alpha:1];
答案 0 :(得分:4)
你在错误的标签上设置它,这应该有效:
cell.detailTextLabel.text=@"An blah blah";
cell.detailTextLabel.textColor = [UIColor colorWithRed:139/255.0f green:136/255.0f blue:120/255.0f alpha:1];
答案 1 :(得分:1)
RGB参数在0到1范围内 将您的0-255值除以255。
if (row == 0)
cell.detailTextLabel.text=@"An blah blah";
cell.textLabel.textColor = [UIColor colorWithRed:139/255.0f green:136/255.0f blue:120/255.0f alpha:1];
另外,也许你的意思是detailTextLabel.textColor而不是textLabel.textColor。
答案 2 :(得分:0)
我不确定你是否为了这个例子,但你应该使用
if (indexPath.row == 0){
cell.detailTextLabel.text=@"detailed text";
cell.textLabel.textColor = [UIColor colorWithRed:139/255.0f green:136/255.0f blue:120/255.0f alpha:1];
return;
}