Last active
August 14, 2018 05:08
-
-
Save keicoder/8683793 to your computer and use it in GitHub Desktop.
objective-c : set background image of a UITableView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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