I want to set an image as the background for my uitableview. This is the code I am using:
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_tableview.png"]];
This is showing the image right but as soon as the table is populated something weird happens. Parts of images are shown in each tableviewcell and also the image scrolls along with the table. How can I make it so that the image remains fixed and that each tableviewcell doesn’t show part of the image?
Thanks,
TC
You don’t want to set the background of the
UITableViewif you don’t want it to scroll. Instead, you want to set the background of theUITableViewto be transparent – and provide your own fixed background behind theUITableView.To do this, first set the background of the UITableView to “Clear Color”.
Programmatically:
self.tableView.backgroundColor = [UIColor clearColor];You’ll also want to un-check the opaque checkbox.
Programmatically:
self.tableView.opaque = NO;Setup the fixed background you want in the view behind the
UITableView.Make sure any sub-views in any of your
UITableViewCells are alsobackgroundColor = [UIColor clearColor];(UITextViews, etc.)