2014-02-22 37 views

回答

1

在这里,下面的代码将帮助您

- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath 
{ 
    if(indexPath.row % 4 == 0) 
     cell.textLabel.textColor =[UIColor redColor]; 
    else if(indexPath.row % 4 == 1) 
     cell.textLabel.textColor =[UIColor blueColor]; 
    else if (indexPath.row % 4 == 2) 
     cell.textLabel.textColor =[UIColor yellowColor]; 
    else if (indexPath.row % 4 == 2) 
     cell.textLabel.textColor =[UIColor greenColor]; 
} 
0

您需要一些代码来决定如何选择颜色。这可以是索引路径行的数组和颜色(%)以选择数组中的索引。然后您想要使用标签的textColorattributedText属性来设置(归属)包括颜色的文本。

相关问题