views:

524

answers:

1

I'm building an iPhone app without the use of Interface Builder. I have set the background of a grouped UITableView in the following manor:

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

I'm trying to fix this background image so that it doesn't scroll with the table cells. Does anyone know how to do this?

+1  A: 

You can place an additional view below UITableView and set its background, so if UITableView is transparent - you'll achieve your goal - it will have correct background and it will not scroll.

Valerii Hiora
This means alpha-blending the UITableView. Have you noticed any performance degradation using this method?
Frank Krueger
I used it on a very simple case and therefore haven't seen any degradation. So the only way to know it is to try it, it shouldn't take much time.
Valerii Hiora
Hmmm... it sounds good, but I'm still having some issues with it. I placed the following code in the ViewDidLoad of my UITableViewController:self.view.backgroundColor = [UIColor clearColor];UIImageView *background = [[UIImageView alloc]initWithImage: [UIImage imageNamed: @"groupedBackground.png"]];[self.view addSubview: background];[self.view sendSubviewToBack: background];Since "background" is still within the tableView, it scrolls with the rest of it, and the cells are not showing up on top of the background image.
treblig
You can create a simple UIViewController and place background + table to the main view.
Valerii Hiora