Samuli Lehtonen
Samuli Lehtonen

Reputation: 3860

iOS using background in normal tableview

I was wondering how I actually use background in normal tableview(non grouped). For example take a look at the clock app and the background there. Any ideas?

Upvotes: 0

Views: 263

Answers (2)

Remy Vanherweghem
Remy Vanherweghem

Reputation: 3955

You can set the background of your table view using the same techniques as the grouped table view (something like self.tableView.backgroundView = anImageView;), but your cells' background are opaque and, therefore, will hide it.

You'll then have to set, in tableView:cellForRowAtIndexPath: the background color of your cells to clearColor [UIColor clearColor] and it's backgroundView to nil.

Run the app now, and there might still be something wrong: the background of the cell's labels is possibly also opaque (I say possibly because the cells might have picked up the cell background color and changed the background color of their subviews accordingly). If it is the case, once again, in tableView:cellForRowAtIndexPath:, set the subviews's background color to clearColor.

Upvotes: 2

Andriy
Andriy

Reputation: 2796

You can also try to set image view with your own image as backgroundView:

UIImage *yourImage = ...
UIImageView *imageView = [[UIImageView alloc] initWithImage:yourImage];
self.tableView.backgroundView = imageView;
[imageView release];

Upvotes: 0

Related Questions