UITableView background Image

前端 未结 12 1998
情歌与酒
情歌与酒 2021-01-29 21:21

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

12条回答
  •  心在旅途
    2021-01-29 22:08

    A little late but maybe for all the others looking for a solution. I could get that work by using the following code in the viewDidLoad method of the UITableViewController:

    self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
    self.tableView.backgroundColor = [UIColor clearColor];
    

    or with using just a background color:

    self.parentViewController.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
    self.tableView.backgroundColor = [UIColor clearColor];
    

    It took me a while to figure that out but now it works like a charm.

提交回复
热议问题