我更改了我的UITableView
(帶有圖案圖像)的backgroundColor,並且我希望我的單元格完全變白,我將backgroundColor
指定爲cell.contentView
。我無法更改accessoryType
的backgroundColor
。我怎樣才能做到這一點 ?無法更改tableView中的indicatorView.backgroundColor查看
這裏是我有什麼暫時的說明:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *bgImg = [UIImage imageNamed:@"backgroundPattern.png"];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:bgImg];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
// Put an arrow
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// In order to have my cell with a white background. I assign a whiteColor
// to my contentView because assign color to the cell.backgroundColor property doesn't
// to work..
cell.contentView.backgroundColor = [UIColor whiteColor];
// HERE is my problem, I would assign a backgroundColor of my accessoryType.
// Because for the moment, just behind the accessoryType this is a the color of the
// tableView.backgroundColor
cell.accessoryView.backgroundColor = [UIColor whiteColor];
}
// Configure the cell...
return cell;
}
如果我將我的顏色分配給contentView,它不起作用。這是因爲它不會改變任何事情。顯示的顏色是tableView.backgroundColor ... – klefevre
對不起,我錯了。看我的編輯。 – LucasTizma
omg我忘了這個委託方法,我無法理解爲什麼Apple強制在這個方法中分配一個單元格backgroundColor,而不是在tableView:cellForRowAtIndexPath:無論如何 – klefevre