Smart code for developers

Sw33tCode header image 2

adding a background image to UITableViewController in a navigation based app

November 14th, 2012 · No Comments

This proved to be an issue for me so I wanted to be a good egg and pass this quick and easy information on to others. If you are using a navigation based app and want to have a custom image for your UITableViewController you want to do something like this:

For iOS 5 and under:
self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myAwesomeImage.png"]];
self.tableView.backgroundColor = [UIColor clearColor];

In iOS 6 the above approach does not work and proved to be buggy. This is the preferred method that I found to work:

UIImageView *boxBackView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myAwesomeImage.png"]];
[self.tableView setBackgroundView:boxBackView];


Tags: iPhone · objective-c

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment