如何更改文本颜色或UITableView单元格?

Cha*_*har 17 cocoa-touch uitableview

我在UITableView中添加了一些数据,但我想更改单元格中显示的颜色或文本.有没有任何委托方法来做这个或任何其他方式????

sha*_*oga 37

不需要标签

你只需要编码:

cell.textLabel.textColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)

或者如果要更改detailTextLabel:

cell.detailTextLabel.textColor = [UIColor blueColor];
Run Code Online (Sandbox Code Playgroud)

祝好运


Ish*_*shu 23

您可以在单元格中添加标签,并根据您设置这些标签的颜色.您还可以添加多个标签并自定义单元格.

只需使用此行

cellLabel.textColor=[UIColor redColor]; //according to you.
Run Code Online (Sandbox Code Playgroud)

  • 没有必要这样做.你可以在我回答的时候做到这一点. (2认同)