0

I have a UITableViewController. In viewDidLoad, I do the following:

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

The background is supposed to be a gradient. Two issues:

  1. Gradient seems to get cut off at the end of the UITableView.
  2. The corners are tinted.

I've experimented with setting the UITableCell's opacity to NO, but that doesn't worked. I have read these threads already: Transparent background in grouped UITableView - iPhone, and Black corners around UITableViewCells.

I'm not using Interface Builder at all for this.

Example:

Example of tinted corners

Community
  • 1
  • 1
Huey
  • 2,714
  • 6
  • 28
  • 34

1 Answers1

1

Make a UIView with that pattern image as background color and set it as table view's background view.

UIView *bgView = [[UIView alloc] initWithFrame:self.tableView.frame];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_cafe.png"]];
self.tableView.backgroundView = bgView;
[bgView release];
Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
  • Thanks! That seemed to work. Can you give the rationale behind doing this vs. what I was doing? – Huey Aug 28 '11 at 21:23
  • I'd like to say you did something wrong :) but it's Apple's engineers that did something wrong. I have submitted countless bug reports about UITableView and UITableViewCell regarding semi-transparent and transparent backgrounds. I had the same problem as you on one of my projects and found this solution by experimenting. – Filip Radelic Aug 28 '11 at 21:25