A: 

Wouldn't that be the background of the view showing through? Have you tried coloring that?

Sneakyness
The UITableView is used directly, but I did try placing it in a view and coloring that. It was still white, dispite that the view's background color was a painfully bright red.
Toon Van Acker
Interesting. What about all the websites that mention things like this? http://www.reigndesign.com/blog/liven-up-your-boring-uitableview-part-1/
Sneakyness
A: 

I don't think you want to override drawRect. Most likely what you're seeing is the background colour of another view or the window, which lies "behind" (i.e. is a superview of) the table view. There's usually a fairly complex layers of UIViews in Apple's UI widgets. Explore the view hierarchy in GDB, look at [myView superview] and then [someSuperView subviews] and try manipulating their BG colours in the debugger to see if you can find which one it is. However, if you implement a fix this way, be warned that it may not be future compatible.

You might also try setting the BG colour of one of the views behind the tableview in Interface Builder (or of the window itself).

sbwoodside
A: 

If you are using a tableviewcell, you can set the view background to be opaque white. Then use

self.tableView.backgroundColor = [UIColor grayColor];

in the view did load method.

Jonah
A: 

I'm sure that that is [UITableView backgroundColor]. You have affected rows, because rows have backgroundColor == clear (or semi-transparent). So, If you'll make rows non-trasparent, all will work fine. This will be solution.

tt.Kilew
+2  A: 

I've only found one way to do this. You have to set the backgroundColor of the UITableView to be transparent, set the backgroundColor of the cell's contentView to whatever colour you want the actual cells to be, then crucially you have to get the light grey colour to appear behind the UITableView. That last step you can do by either setting the backgroundColour of the UIWindow, or of whatever is containing or your tableViewController.

So, assuming you have a view controller that is derived from UITableViewController, insert these lines in the -(void)viewDidLoad method:-

// sets the background of the table to be transparent
self.tableView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.0];
// assuming we are inside a navigation or tab controller, set the background
self.parentViewController.view.backgroundColor = [UIColor lightGrayColor];

Then inside the part of tableView:cellForRowAtIndexPath: that creates new cells, add:-

// set an opaque background for the cells 
cell.contentView.backgroundColor = [UIColor whiteColor];
U62
Using transparent backgrounds is the very last resort. It will affect scrolling performance tremendously. Simply adding a gray subview to the UIListView gives the wanted effect, is more customizable, and has no bad effects on performance.
PeyloW
Like I said, I tried all the obvious ways to achieve this effect, like all the things the other answers suggest and none of those worked. I'm the only one to provide a working solution and no, it does not affect scrolling performance at all - I've tried it on the simulator and the device. But thanks to your downvote, my solution has the save votes as all the wrong answers.
U62
+5  A: 

Setting transparencies is bad for performance. What you want is the gray area above the search bar, but it should still be white beyond the end of the list.

You can add a subview to your UIListView that lives above the content instead.

CGRect frame = self.list.bounds;
frame.origin.y = -frame.size.height;
UIView* grayView = [[UIView alloc] initWithFrame:frame];
grayView.backgroundColor = [UIColor grayColor];
[self.listView addSubview:grayView];
[grayView release];

You could add more fancy stuff to the view if you like, perhaps a fade, or a divider line without subclassing UISerchBar.

PeyloW
+3  A: 

This is one of my very favorite tricks.

UIView *topview = [[[UIView alloc] initWithFrame:CGRectMake(0,-480,320,480)] autorelease];
topview.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:238.0/255.0 alpha:1];

[self.tableView addSubview:topview];

Basically you're creating a big view the size of the screen and placing it "above" the content area. You'll never be able to scroll up past it.

And don't worry about the memory impact of a UIView that's 320x480 pixels, it won't consume any significant memory because the CALayer doesn't have any meaningful content.

Nick Farina
This is what most apps do. It is however possible to scroll past a whole screen's worth by flicking the scrollview very rapidly, which is why I prefer to place the coloured view statically behind the tableview and have the tableview's background transparent (but with solid backgrounded cells views.
U62
A: 

I followed the tip outlined by Peylow, for a UITableView, by simply adding a subview. My only change from the code was to grab a color a bit closer to the one used in Apple apps, plus I got it a bit closer to Apple's look of having a line above the UISearchbar by reducing the frame origin y coordinate by one pixel:

frame.origin.y = -frame.size.height - 1
petert