Scrolling background image for UITableView?

There are currently many answers on how to set up a custom fixed background for a UITableView. But is there a trick to making the background image scrollable along with the table cells?

Thanks!

+7
iphone cocoa-touch uitableview
source share
5 answers

You must set the background image through the backgroundColor property of the UITableView:

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]; 
+6
source share

.

 UIImageView *background = [[UIImageView alloc]initWithImage: [UIImage imageNamed: @"background.jpg"]]; [tableView addSubview: background]; [tableView sendSubviewToBack: background]; 
+3
source share

I think the answer is to subclass UITableView and override layoutSubviews. In a UITableView, you must create a property that points to a background UIImageView.

When you override layoutSubviews just write

 -(void) layoutSubviews { [self sendSubviewToBack: backgroundImageView]; [super layoutSubviews]; } 
+3
source share

This answer may also be helpful. Background image that scrolls and synchronizes with UITable scroll

This is due to a little cheating with table views.

You need to create a separate background table that is subordinate to your foreground table, and uses KVO to listen to the contentOffset property to represent the foreground table.

0
source share

The possible answer was - obviously - already in stackoverflow:

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

Link: iPhone - setting background on UITableViewController

Edit: This is not a perfect answer, I know :)

-6
source share

All Articles