I'm working on a project. I have plenty of UITableView
s which are set as clear color. Their views' background color are set to my custom color and everything is fine on iPhone.
The issue comes up on iPad! I tried almost everything, but my UITableView
has a white color.
I checked the other topics, like: UITableView backgroundColor always gray on iPad, but nothing worked. Also, my problem is not grey, it's white as snow!
What might be the reason of it?
This can be achieved in a Storyboard as follows:
Result: iPad and iPhone simulator views look the same
Building off of Ben Flynn's answer... cell.contentView background color is not necessarily equal to the cell.background color. In which case, I found that this worked in resolving the iPad white background issue in more situations:
While the statement looks ridiculous and crazy... it resolves the issue.
Instead of setting the background color, trying using a background view instead, like this:
I've had problems where using the backgroundColor doesn't always produce an effect, but setting a background view instead works fine.
In my experience, some versions of iOS set UITableViewCell's backgroundColor before calling the delegate's
tableView:willDisplayCell:forRowAtIndexPath:
. Resetting back to your custom color in that method fixes it.This seems to be fixed with iOS 10 Beta 4 as mentioned in release notes under
UIKit
notes:You can fix this by making an appearance API setting in your appDelegate file :
Swift: