Я зашел так далеко, что использовал следующий код для установки цвета фона ячейки TableView (в cellForRowAtIndexPath)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.backgroundColor = [UIColor yellowColor];
cell.contentView.backgroundColor = [UIColor yellowColor];
UIView* backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ];
backgroundView.backgroundColor = [ UIColor yellowColor ];
cell.backgroundView = backgroundView;
for ( UIView* view in cell.contentView.subviews )
{
view.backgroundColor = [ UIColor yellowColor ];
}
}
// Set up the cell...
if ([[menuList objectAtIndex:indexPath.row] isKindOfClass:[Category class]])
{
cell.text = ((Category *)[menuList objectAtIndex:indexPath.row]).name;
}
else
{
[cell setText: [menuList objectAtIndex:indexPath.row]];
}
return cell;
}
Однако, когда он рендерит только часть ячейки, фон применяется примерно так (где z - заливка bg), даже фоном Аксессуара является цвет, а не текст.
xxxxxxxxxxxxxxxxxxxx
zzzSearch
xxxxxxxxxxxxxxxxxxxx
Единственный способ изменить фон текста - установить цвет фона для всей таблицы в Интерфейсном Разработчике