Reputation: 1595
This concerns iPhoneOS-sdk-3.2
I am having difficulty changing the border color of a grouped UITableView. I can change the cell background color, separator color, text color, quite easily now, and the rounded corners clip correctly, even when highlighted with whatever colors I have chosen. However the surrounding border remains infuriatingly gray despite many different attempts.
I have read all of the related posts I can find via Google, let alone stackoverflow. I have seen Mike Akers' heroic PITA solution for UITableViewCell clipping -- this problem is solved for iPhoneOS 3.0 and it did not help me with the border.
I have tried both a programmatic and xib-based solution and both provide the same results.
I will share the programmatic version below:
I have a UIViewController subclass rather than a UITableViewController subclass to act as a UITableView delegate -- I chose this route as I am coding on the iPad and UITableViewController reportedly takes over the whole screen. loadView method of my UIViewController subclass:
- (void) loadView {
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[self.view release];
self.view.backgroundColor = [UIColor blackColor];
// add and configure UITableView
CGRect tableViewRect = CGRectMake(0., 0., 256., 768.);
myTableView = [[UITableView alloc] initWithFrame:tableViewRect style:UITableViewStyleGrouped];
// set the tableview delegate to this object and the datasource to the datasource which has already been set
myTableView.delegate = self;
myTableView.dataSource = self;
myTableView.sectionIndexMinimumDisplayRowCount = 1;
myTableView.backgroundColor = [UIColor clearColor];
myTableView.separatorColor = [UIColor whiteColor];
myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
myTableView.opaque = NO;
// add the table view to our background view
[self.view addSubview:myTableView];
[myTableView release];
}
Upvotes: 1
Views: 6061
Reputation: 1595
I found a solution. This behavior does appear to be iPhoneOS 3.2 specific as Apple added a backgroundView property for UITableView in iPhoneOS 3.2.
I tried [myTableView.backgroundView removeFromSuperView] and UITableView just replaced it with another.
Instead, my solution was to add:
myTableView.backgroundView.hidden = YES;
Upvotes: 5