我有一个UITableViewController,我正试图自定义其样式。我已经完成了95%,但是无法删除单元格背景中的奇怪遮蔽。我在此屏幕截图中突出显示了我要删除的内容:
为了解决这个问题,我卸载了构成UITableView的所有视图,然后对它们进行了着色以尝试找到需要更改的视图:
如您所见,我无法对那个特定位置进行着色。换句话说,我找不到与该位置相关联的视图。
如何从我的单元格中移除该遮蔽?
如何从我的单元格中移除该遮蔽?
backgroundView
属性 - 使用您的图像创建一个图像视图,并将其设置为背景视图,或者创建一个UIView并将其背景颜色设置为您上面所做的那样。您需要删除任何设置背景颜色的代码,并确保您的节标题视图具有清晰的背景或对比背景。作为一个简单的演示,我已经创建了一个组合表视图,将其背景颜色设置为透明,并在表视图控制器的viewDidLoad
中添加了以下代码:- (void)viewDidLoad
{
[super viewDidLoad];
UIView *backgroundView = [[UIView alloc] initWithFrame:self.tableView.bounds];
CAGradientLayer *layer = [CAGradientLayer layer];
layer.colors = [NSArray arrayWithObjects:(id)[UIColor redColor].CGColor,(id)[UIColor whiteColor].CGColor, nil];
layer.frame = backgroundView.frame;
[backgroundView.layer addSublayer:layer];
self.tableView.backgroundView = backgroundView;
}
initWithNibName
中使用以下代码设置背景:self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"GC_TestWeight-red-background.jpg"]];
- Gavin Miller