Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewController - Fixed Background Image

Is it possible to fix the position of a UITableViewController background image?

I've added the background image via the viewdidload method with the following code -

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blurredBGW"]];

But as the table is fairly long (and also contains static cells if that matters) it scrolls (and repeats) as you scroll down the table.

like image 346
Dancer Avatar asked Jan 15 '14 17:01

Dancer


3 Answers

you can try to add the background image as UIView and not as UIColor, try this:

 self.tableView.backgroundView = [[UIImageView alloc] initWithImage:
                                 [UIImage imageNamed:@"blurredBGW.png"]];
like image 141
Ilario Avatar answered Oct 17 '22 09:10

Ilario


for swift version 3.0.try this code.it will set a fixed background to a table view controller

 self.tableView.backgroundView = UIImageView(image: UIImage(named: "background.png")!)
like image 3
Rajesh.k Avatar answered Oct 17 '22 09:10

Rajesh.k


UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg.png"]];
[tempImageView setFrame:self.tableView.frame];

self.tableView.backgroundView = tempImageView;
like image 1
Mr.OFF Avatar answered Oct 17 '22 10:10

Mr.OFF