tags:

views:

4013

answers:

3

I have a UIView with a UITableView for a subview. The UIView has an image applied to its background via setBackGroundColor, and I have applied a background to the UITableView in the same manner. Both images are PNGs, and the the background for the UITableView has levels of transparency in it that don't appear to be working -- the PNG seems to be rendered without regard to the transparency data within it -- I should be seeing the background of the UIView through it. The basic code I am using for applying the background images is:

UIImage *patternImage = [UIImage imageNamed:@"background.png"];
[tableContainer setBackgroundColor:[UIColor colorWithPatternImage: patternImage]];

I'm stumped. Any ideas?

+1  A: 

You need to make sure your table view is not opaque.

In Interface Builder, uncheck your table view's 'Opaque' setting. Or, in code,

tableView.opaque = NO;

Keep in mind that any sort of transparency in regard to table views will slow performance dramatically. If you only have a few rows, you'll probably be OK, but if you do any scrolling, be prepared for some pain. Make sure you test on a real device before release.

August
A: 

Thank you so much, it's exactly what I was looking for (for the past hour), but only does part of the problem.

No when I send reloadData to the UITableView each cell has the background, but the opacity isn't carried through... when the table first loads, I see the repeating pattern of cells and the transparency is correct, but after reloadData the cell's aren't transparent anymore.

pixel
+1  A: 

Turns out that I needed to set the backgroundColor of the cell's contentView rather than setting the backgroundColor of the cell itself.

Thanks again for the help!

pixel