Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView clear background

I realize that iOS 7 has not officially been released and we should not discuss it BUT I am going crazy trying to figure out this problem. On iOS 6, my table view was transparent and looked great. First time running iOS 7, and the background is white.

I have tried making the table backgroundColor, cell color etc etc to UIColor clearColor but have no change.

How to fix this problem?

the table

like image 796
Teddy13 Avatar asked Sep 12 '13 00:09

Teddy13


3 Answers

    // Fix for iOS 7 to clear backgroundColor
    cell.backgroundColor = [UIColor clearColor];
    cell.backgroundView = [[UIView new] autorelease];
    cell.selectedBackgroundView = [[UIView new] autorelease];

in cellForRowAtIndexPath

Also, make sure that your tableview actually has transparent background (in storyboard): enter image description here

like image 156
slamor Avatar answered Oct 01 '22 22:10

slamor


Put this:

cell.backgroundColor = [UIColor clearColor];

In this section:

cellForRowAtIndexPath
like image 34
Maximus Vermillion Avatar answered Oct 02 '22 00:10

Maximus Vermillion


Try setting backgroundView to nil first.

[self.tableView setBackgroundView:nil];
[self.tableView setBackgroundColor:[UIColor clearColor]];

Not sure if this is a change in documentation with iOS7 or has always been there and just did not affect background color, but per UITableView Class Reference @property backgroundView

"You must set this property to nil to set the background color of the table view."

edit: corrected code syntax

like image 44
dandan Avatar answered Oct 01 '22 23:10

dandan