Getting a background texture behind a UITableView
In many apps when you viewing the top of a UITableView and you pull down you get one of three things: a plain white background (i.e. YouTube), a pull to refresh (i.e. twitter), or a textured or differently colored background (i.e. contacts). By default when you have a UITableView, you will get the first option, a plain white background.
If however you would like to do something like contacts where the perceived “background” of the table view is something other than default. If that’s the case, it’s relatively easy to do. Here’s how.
In your UITableViewController (usually viewDidLoad:)
// This sets the lighter linen looking background. see UIColor for more "System Colors" [[[self navigationController] view] setBackgroundColor:[UIColor underPageBackgroundColor]]; // Make the background of the table view transparent. [[self tableView] setBackgroundColor:[UIColor clearColor]]; |
Then implement this method in your UITableViewController:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { [cell setBackgroundColor:[UIColor whiteColor]]; } |
After playing around and failing in different ways, this seems to be the simplest solution by far. Simple, easy and does what it should.