iOS 8.1 UITableview Background Colour always white
So I've tested this in iOS 7.1 and it works fine. I'm setting the background colour to clear on my tableview using the lines below.
self.tableview = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStylePlain];
self.tableview.delegate = self;
self.tableview.dataSource = self;
self.tableview.backgroundView = nil;
self.tableview.backgroundColor = [UIColor clearColor];
self.tableview.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
[self addSubview:self.tableview];
I'm also setting the tableFooterView to a new view to hide any left over unused cells using.
self.tableview.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
This works beautifully on iOS 7 but in iOS 8 I'm left with a white background colour for the space under the tableview. The superview the tableview sits inside also has a background colour of clear. Any ideas?
Added images below - I've had to obscure the client name
Working on iOS 7
Not working on iOS 8.1
Apple document says
... In iOS 7, cells have a white background by default; in earlier versions of iOS, cells inherit the background color of the enclosing table view. If you want to change the background color of a cell, do so in the tableView:willDisplayCell:forRowAtIndexPath: method of your table view delegate.
You might need to use willDisplayCell UITableView delegate method to have a transparent background for your table view .
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell setBackgroundColor:[UIColor clearColor]];
}
For me, this is what worked (I am using a custom UITableViewCell
in its own XIB):
UIColor.clearColor()
programatically in viewDidLoad . Doing it in the Storyboard doesn't work. 上一篇: 从git重置恢复