我想在数据库中显示表视图单元格的数据,所以我想根据第一个单元格灰色的数据方式给单元格颜色然后再下一个棕色的单元格我想要显示灰色单元格,所以任何人都可以告诉我什么是最简单的程序.
先生和问候,Priyanka.
如果您指的是单元格的背景颜色,则更改它的最简单方法:
cell.backgroundView.backgroundColor = [UIColor greenColor];
Run Code Online (Sandbox Code Playgroud)
看起来像:
- (UITableViewCell *) tableView:tableView cellForRowAtIndexPath:indexPath
{
cell = ... // dequeue or initialize cell
switch (criteriaFromDatabase)
{
case 0:
cell.backgroundView.backgroundColor = [UIColor greenColor];
break;
case 1:
cell.backgroundView.backgroundColor = [UIColor blueColor];
break;
default:
cell.backgroundView.backgroundColor = [UIColor redColor];
break;
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3022 次 |
| 最近记录: |