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.
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.
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.
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.
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,
backgroundViewwas often the most reliable way to control cell background appearance. - Check the table view background as well as the cell itself.
- '
contentViewstyling 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
- UITableViewCell subview disappears when cell is selected
- UITableViewCell with UITextView height in iOS 7?
- UITableViewHeaderFooterView Unable to change background color
- UITapGestureRecognizer - make it work on touch down, not touch up?
- UITextField value changed not firing when field is updated
- Unable to access my minikube cluster from the browser ❗ Because you are using a Docker driver on windows, the terminal needs to be open to run it.
- UITapGestureRecognizer - single tap and double tap
- UITapGestureRecognizer breaks UITableView didSelectRowAtIndexPath
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.