Search code examples
iosobjective-cxcodeuitableviewios9

UITableView background color iOS 9


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]];

Solution

  • Objective-c:

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

    Swift:

    self.yourTableView.backgroundColor = .clear
    

    XCode 7.0 bug. Not picking up from Storyboard