Thornaci Thornaci - 2 months ago 15
iOS Question

UITableView background image for all cells

I want to change my tableview background image. When i change it, the change doesn't effect the cells. I'm using xib for my cells which doesn't have any code inside it, just design. So how can i solve this?

self.list.backgroundView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"Pattern.png"]];


tableview

Answer

In your cellForRowAtIndexPath method, set your cell's background color to clear color. It will make your cells transparent and show the background image.

Objective C:

cell.backgroundColor = [UIColor clearColor];

Swift:

cell.backgroundColor = UIColor.clearColor()