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
You can fix this by making an appearance API setting in your appDelegate file :
Swift:
UITableViewCell.appearance().backgroundColor = UIColor.clearColor()
This solve this issue for me
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
tableView.backgroundColor = UIColor.clear
}
SWIFT
This was a happening to me, too. My table view in my SWRevealViewController appeared white on my iPad when it looked clear (which is how I wanted it with a background image) on my iPhone. I tried all of the above but this is what ended up working for me in my viewDidLoad().
tableView.backgroundView = UIImageView(image: UIImage(named: "gray"))
tableView.backgroundView?.backgroundColor = .clearColor()
UITableViewCell.appearance().backgroundColor = .clearColor()
I've worked around this bug by placing this in my UITableViewCell
subclass:
When the cell is being loaded from the NIB file:
override func awakeFromNib() {
super.awakeFromNib()
self.backgroundColor = UIColor.clear
}
and when the cell is being reused by the system
override func prepareForReuse() {
super.prepareForReuse()
self.backgroundColor = UIColor.clear
}
iOS 10 is supposed to fix this issue in Interface Builder, as animeshporwal said.
I have a transparent table view with semi-transparent table view cells. I set the table view background color to clear when I create the table. This works for all iOS/device combinations except iPad + iOS 8, where the background color remains white.
For me, setting the cell's background color to semi-transparent and the content view background color to clear works, since I do it on each tableView(_ tableView: UITableView, cellForRowAt indexPath)
. The problem for me was only that the table view background remained white.
I tried all combinations that I did find regarding this issue, but the only thing I actually needed to to was to set the table views background to transparent on each tableView(_ tableView: UITableView, cellForRowAt indexPath)
. Not super-intuitive, but at least it works. :P
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.