8

I have a UITableView that I want to set its background color to transparent. Background color for the table view and all subviews at interface builder is set to transparent. It works fine for iOS 8 & 7. but, not iOS 9. any idea?

cellForRowAtIndexPath method:

[cell setSelectedBackgroundView:[[UIView alloc] init]];
[cell.selectedBackgroundView setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundColor:[UIColor clearColor]];
[cell.contentView setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView setBackgroundColor:[UIColor clearColor]];
hasan
  • 23,815
  • 10
  • 63
  • 101
  • First, this is not a good idea because the scrolling performance will suffer. Apart from that, I think it's a bug. File a radar. – dasdom Aug 09 '15 at 12:57
  • have to tried `cell.contentView.backgroundColor` ? try digging a little more, before reporting.. hmm.. i'm also thinking that it's a bug. – 0yeoj Aug 09 '15 at 13:18

2 Answers2

10

Objective-c:

[self.yourTableView setBackgroundColor:[UIColor clearColor]];

Swift:

self.yourTableView.backgroundColor = .clear

XCode 7.0 bug. Not picking up from Storyboard

hasan
  • 23,815
  • 10
  • 63
  • 101
Vipulk617
  • 799
  • 1
  • 7
  • 23
-1

This happens to me even when creating an UITableView in code, and setting it as a private property of my UIViewController. However, if the UITableView is a global variable, this problem does not occur.

I suspect Apple is rooting around the ivars on my UIViewController, setting UITableView's background colors to UIColor whiteColor without asking me. I have checked, and the calls to do go through setBackgroundColor on the UITableView.

John
  • 706
  • 2
  • 10
  • 16