Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView background Image

I'am trying to setup a png image as my tableview's background. With the following code all are fine! But only on iPhone Simulator. If I try to run the application on an iPhone device the background of tableview remains white (or clear). Do you thing thing that is something about the way I tried to set the background color. I have been trying many ways until the following, but all have the same issue.

self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.opaque = NO; self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TableViewBackground.png"]]; 

Thank you in advance!

like image 856
user730153 Avatar asked Apr 28 '11 21:04

user730153


1 Answers

Please use following code.

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

Thanks,

like image 137
Ravin Avatar answered Sep 18 '22 13:09

Ravin