这涉及 iPhoneOS-sdk-3.2
我很难更改分组 UITableView 的边框颜色。我现在可以很容易地更改单元格背景颜色、分隔符颜色、文本颜色,并且圆角剪辑正确,即使用我选择的任何颜色突出显示也是如此。然而,尽管进行了许多不同的尝试,但周围的边界仍然是灰蒙蒙的。
我已经阅读了我可以通过 Google 找到的所有相关帖子,更不用说 stackoverflow。我已经看到 Mike Akers 针对 UITableViewCell 裁剪的英勇 PITA 解决方案——这个问题在 iPhoneOS 3.0 中得到了解决,但它对我的边框没有帮助。
我已经尝试过编程和基于 xib 的解决方案,并且都提供了相同的结果。
我将在下面分享程序化版本:
我有一个 UIViewController 子类而不是 UITableViewController 子类来充当 UITableView 委托——我在 iPad 上编码时选择了这条路线,据报道 UITableViewController 接管了整个屏幕。我的 UIViewController 子类的 loadView 方法:
- (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];
}