Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2: How the Table Fits Together > Controlling the Background of a UITabl...

Controlling the Background of a UITableView

Setting an image as the background of a UITableView is possible, albeit slight convoluted. There are four steps:

  1. Set the backgroundColor property of your tableView to clearColor, so that the background image is visible.
    [myTableView setBackgroundColor:[UIColor clearColor]];
  2. Create an instance of a UIImageView and set its image property to the image that you want to appear behind the table.
    UIImageView *tableBackgroundView = [[UIImageView alloc] image
    initWithImage:[UIImage imageNamed:@"myImage"]];
  3. Set theUIImageView’sframe property so that it’s the same size as that of the tableView:
    [tableBackgroundView setFrame: myTableView.frame];
  4. Update the tableView’sbackgroundImage property to point to your new UIImageView object:
    [myTableView setBackgroundView:tableBackgroundView];

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial