Dar*_*ren 29 xcode cocoa-touch uitableview ios
我有一个静态的UITableView,所有内容都放在故事板上.在cellForRowAtIndexPath中我只是使用
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)
而且tableview效果很好.但是我想将单元格背景设置为[UIColor clearColor]我该怎么做?该表有30个单元格,每个单元格不同.
谢谢
Jon*_*lis 63
我不完全确定这是否有效,因为我从未尝试过使用它super来管理细胞.如果您的代码适用super,那么您应该可以通过这样做来设置背景颜色:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
无论哪种方式,在我看来,这似乎是一种奇怪的做事方式.通常,根据默认的UITableViewboiletplate代码,在方法本身中创建和重用单元格,而不调用super.
CSm*_*ith 18
试试这个委托方法:
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor clearColor];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19044 次 |
| 最近记录: |