UITableView与静态单元格没有cellForRowAtIndexPath。如何设置清晰的背景? [英] UITableView with static cells without cellForRowAtIndexPath. How to set clear background?
问题描述
我有一个静态的UITableView,一切都在故事板上。在cellForRowAtIndexPath我只需使用
I have a static UITableView and everything is laid out on the Storyboard. In cellForRowAtIndexPath i simply use
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
和tableview工作伟大。但是我想将单元格的背景设置为[UIColor clearColor]
我该怎么做呢?
and the tableview works great. However I want to set the cells backgrounds to [UIColor clearColor] How can I do this? The table has 30 cells, each one different.
感谢
推荐答案
我不完全确定这将工作,因为我从来没有尝试使用 super
来管理单元格。如果你的代码使用 super
,那么你应该可以通过这样做来设置背景颜色:
I'm not entirely sure if this will work, because I've never tried using super
to manage the cells. If your code works with super
, then you should be able to get away with doing this to set the background color:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
无论如何,这似乎在我看来是一种奇怪的做事方式。通常,在方法中创建和重用单元格,根据默认的 UITableView
boiletplate代码,而不调用 super
。
Either way, this seems to me like a strange way of doing things. Normally the cells are created and reused in the method itself, as per the default UITableView
boiletplate code, without calling super
.
这篇关于UITableView与静态单元格没有cellForRowAtIndexPath。如何设置清晰的背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!