开发者

changing uifont color in a table cell

i am trying to change the color of the cell using the following code, however it displays all the cell's as white font instead of the gold rgb color code i have.

if (row == 0)

    cell.detailText开发者_运维问答Label.text=@"An blah blah";
    cell.textLabel.textColor = [UIColor colorWithRed:139 green:136 blue:120 alpha:1];


You're setting it on the wrong label, this should work:

cell.detailTextLabel.text=@"An blah blah";
cell.detailTextLabel.textColor = [UIColor colorWithRed:139/255.0f green:136/255.0f blue:120/255.0f alpha:1];


The RGB parameters are in the range 0 to 1.
Divide your 0-255 values by 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];

Also, maybe you meant detailTextLabel.textColor instead of textLabel.textColor.


I'm not sure you did if to the sake of the example but you should use

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜