iOS7
UITableViewCell
white background issue
iOS development
debugging

UITableViewCell show white background and cannot be modified on iOS7

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On iOS 7, table views and cells picked up a flatter visual style that made background behavior feel different from earlier versions. If a UITableViewCell keeps appearing white even after you set colors, the issue is usually that you are styling the wrong view, or that the table view and cell background views are still using default system behavior.

Understand Which View Is Actually Visible

A table cell has several layers that can affect what color you see:

  • the table view background
  • the cell's backgroundColor
  • the cell's backgroundView
  • the cell's contentView
  • the selectedBackgroundView

On iOS 7, setting only one of these was often not enough to get the final appearance you expected.

A Reliable Customization Pattern

A common fix is to provide a custom backgroundView.

objective-c
1- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
2    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
3
4    UIView *bg = [[UIView alloc] initWithFrame:CGRectZero];
5    bg.backgroundColor = [UIColor lightGrayColor];
6    cell.backgroundView = bg;
7
8    UIView *selected = [[UIView alloc] initWithFrame:CGRectZero];
9    selected.backgroundColor = [UIColor darkGrayColor];
10    cell.selectedBackgroundView = selected;
11
12    cell.contentView.backgroundColor = [UIColor clearColor];
13    return cell;
14}

Using backgroundView is often more reliable than changing only backgroundColor directly.

Also Check the Table View Itself

Sometimes the cell seems white because the table view background is showing through.

objective-c
self.tableView.backgroundColor = [UIColor blackColor];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

If the table view remains white and the cell content is transparent, the overall result still looks white even though the cell is technically being styled.

contentView Versus Cell Background

If you add subviews only to contentView, those subviews do not automatically change the cell's outer background behavior. This is why developers often see text and custom controls over what looks like an unchangeable white rectangle.

Think of contentView as the content layer, not the full styling surface.

Custom Cell Subclassing Helps

If the appearance is reused across the app, a custom cell subclass is cleaner.

objective-c
1- (void)awakeFromNib {
2    [super awakeFromNib];
3
4    UIView *bg = [[UIView alloc] initWithFrame:CGRectZero];
5    bg.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
6    self.backgroundView = bg;
7}

This keeps visual setup close to the cell implementation instead of scattering it through table view delegate code.

Historical Context

Because this is an iOS 7-era issue, some odd behavior came from adapting pre-iOS 7 appearance techniques to the redesigned table view look. The practical fix was usually not a special iOS 7 hack so much as using the right cell background properties consistently.

Check Reuse Behavior Too

Because table view cells are reused, appearance code must run consistently whenever the cell is configured. If one path sets a custom background view and another path leaves the reused cell in its old state, the visual result can look random and device-specific.

That is why cell background styling should live in one predictable setup path, not in scattered conditional branches.

Common Pitfalls

A common mistake is setting only cell.backgroundColor and expecting that to override every visible layer.

Another mistake is customizing contentView and forgetting the table view or cell background view is still white.

Developers also often forget to set selectedBackgroundView, so the cell looks correct when idle and suddenly flips to an unexpected white or blue style during selection.

Summary

  • A UITableViewCell's visible background can come from several different view layers.
  • On iOS 7, backgroundView was often the most reliable way to control cell background appearance.
  • Check the table view background as well as the cell itself.
  • 'contentView styling alone does not control the entire cell background.'
  • If the cell still looks white, inspect backgroundView, selectedBackgroundView, and the table view background together.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.