UITableViewCellStyleSubtitle标签的背景颜色?
我正在尝试创建一个以图像为背景的表。 为了实现这一目标,我从以下背景开始:UITableViewCellStyleSubtitle标签的背景颜色?,uitableview,background,Uitableview,Background,我正在尝试创建一个以图像为背景的表。 为了实现这一目标,我从以下背景开始: self.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; 这导致背景图像也出现在tablecells中。这不是我想要的,所以我尝试设置单元格的背景颜色: cell.backgroundColor = [UIColor whiteColor]; 这一点效果都没有!!!。嗯,奇怪。 所以我试了一下: UIView *backgroundVie
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
这导致背景图像也出现在tablecells中。这不是我想要的,所以我尝试设置单元格的背景颜色:
cell.backgroundColor = [UIColor whiteColor];
这一点效果都没有!!!。嗯,奇怪。
所以我试了一下:
UIView *backgroundView = [[UIView alloc] init];
backgroundView.backgroundColor = [UIColor whiteColor];
cell.backgroundView = backgroundView;
[backgroundView release];
这几乎奏效。剩下的唯一问题是textLabel&detailTextLabel仍然显示它们后面的背景。
将这些标签上的背景色设置为白色也没有任何作用
我该如何进行?我哪里出错了?我正在尝试实现像worldClock应用程序一样的tableView。要更改table view单元格的背景颜色,您需要在
tableView:willDisplayCell:ForRowatineXpath:
中设置它,而不是tableView:CellForRowatineXpath:
否则不会产生任何效果,例如:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor whiteColor];
}
我仍然不完全理解为什么使用cellForRowAtIndexPath:不起作用,但你已经解决了我的问题。谢谢