Skip to content

Instantly share code, notes, and snippets.

@keicoder
Last active August 14, 2018 05:08
Show Gist options
  • Save keicoder/8683793 to your computer and use it in GitHub Desktop.
Save keicoder/8683793 to your computer and use it in GitHub Desktop.
objective-c : set background image of a UITableView
//set background image of a UITableView
//ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
//Controlling the Background of a UITableView
//setting an image as the background of UITableView through four steps
//1.set backgroundColor property of tableView to clearColor, so that background image is visible
[self.tableView setBackgroundColor:[UIColor clearColor]];
//2.create an UIImageView that you want to appear behind the table
UIImageView *tableBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage"]];
//3.set the UIImageView’s frame to the same size of the tableView
[tableBackgroundView setFrame: self.tableView.frame];
//4.update tableView’s backgroundImage to the new UIImageView object
[self.tableView setBackgroundView:tableBackgroundView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment