Search code examples
iphoneobjective-cxcodexcode4xcode4.2

UITableViewController Background Image


How can I set an image for UITableViewController?

I have used many things but it doesn't help me to set the image as background

UIImageView* bgView = [[[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"Default.png"]] autorelease];

[tableView.backgroundView addSubview:bgView];

And this

[[self view] setAutoresizesSubviews:NO];

UIView *backgroundView = [[UIView alloc] initWithFrame:self.view.frame];
backgroundView.backgroundColor = 
  [UIColor colorWithPatternImage:
    [UIImage imageNamed:@"Default.png"]];

self.tableView.backgroundView = backgroundView;
self.tableView.backgroundColor = [UIColor clearColor];

[backgroundView release];

And

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

None of it worked for me.


Solution

  • sets the background fill mode

    [youTable setBackgroundView:
      [[UIImageView alloc] initWithImage:
        [UIImage imageNamed:@"bg.png"]]];
    

    sets the background mode tile

    [youTable setBackgroundColor:
      [UIColor colorWithPatternImage:
        [UIImage imageNamed:@"bg.png"]]];