iPhone - Setting background on UITableViewController

后端 未结 6 1542
借酒劲吻你
借酒劲吻你 2020-12-04 10:50

Is there any way to set a background view on a UITableViewController?

I try with the code I am using on a UIViewController, but the view comes over all

6条回答
  •  Happy的楠姐
    2020-12-04 11:24

    (This is basically the same as Hans Espen's solution above, but uses convenience methods for brevity)

    Put this in your -[UITableViewControllerSubclass viewDidLoad] method:

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

    There's no point in avoiding a couple of autoreleases in a viewDidLoad method, since it only gets called rarely (when the view actually loads) and will therefore have negligible impact on performance.

    N.B. You should always use PNG images on the iPhone, not JPEG or any other format.

提交回复
热议问题