uitableview单元格背景问题

时间:2013-08-26 16:12:20

标签: uitableview ios7

好的,从iOS 7 Beta 6开始,它就被打破了。

在启动时,我将表格视图的背景更改为图像(如果我将其设置为颜色,它会执行相同的操作)并且表格单元格为白色...

当我选择一个单元格时,转到下一个视图,然后返回到该视图...单元格与视图背景相同(除了我选择的单元格)...

这是我设置背景的地方......

- (void)viewWillAppear:(BOOL)animated {

pacListTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"dotted-pattern.png"]];
pacListTableView.backgroundView = nil;

[super viewWillAppear:animated]; 

}

有什么想法吗?它适用于iOS及以下版本。

2 个答案:

答案 0 :(得分:5)

尝试设置表格视图单元格的背景颜色以清除颜色。直到IOS 7默认背景是清晰的颜色。但是对于IOS 7,它已经变成了白色。因此,您必须手动将其设置为清除颜色。

答案 1 :(得分:1)

使用iOS7时,单元格的默认backgroundColor为白色而不是clearColor。您必须在单元格的contentView上显式设置所需的backgroundColor(而不是在单元格本身上)。

所以在你的情况下你必须插入

cell.contentView.backgroundColor = [UIColor clearColor];

 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
相关问题