views:

1382

answers:

4

I've seen some iPhone applications that use a custom image as the background for a grouped UITableView, instead of the standard gray lines.

How is this achieved?

+2  A: 

In another project (developed using 2.2.1) I did this by setting my UITableView's background opacity to 0%, and then simply layering a UIImageView behind it using Interface Builder. This allowed me to have a fixed background regardless of the table state. You can also set the background of the UITableView to be an image instead, but then the background scrolls with the table. (I don't have the code handy at the moment, but I got the tip a while back on the Apple developer forums).

Note that this can cause some performance issues. Apple discourages using transparency whenever possible because the GPUs on the pre-3GS models aren't particularly beefy.

Shaggy Frog
+1  A: 

You can use the +[UIColor colorWithPatternImage:(UIImage)] method like so:

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Background.png"]];
Garrett
A: 

the problem with colorWithPatternImage: is that you need to use "patterned" images, otherwise your image will be tiled randomly

this link has a simple solution, if you want all your views to have the same background

http://howtomakeiphoneapps.com/2009/03/how-to-add-a-nice-background-image-to-your-grouped-table-view/

camilin87
+1  A: 

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

self.tableView.separatorColor = [UIColor clearColor];

self.tableView.backgroundColor = [UIColor clearColor];

Hope this will help.It won't display hideous translucent background behind the cells especially in case of Grouped UITableView.

Honey www.panipurisoft.com