Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top