【发布时间】:2011-12-02 07:07:48
【问题描述】:
注意:这是关于GROUPED tableView 中的一个单元格。与普通的 tableView 相比,这有很大的不同!默认单元格自定义答案在这种情况下不起作用,因此请先验证您的答案。
这是我设置灰屏和黄色tableView背景的方式:
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor grayColor];
UIView *myView = [[UIView alloc] initWithFrame:magicRect];
myView.backgroundColor = [UIColor yellowColor];
[self.tableView addSubview:myView];
[self.tableView sendSubviewToBack:myView];
}
这就是我设置绿色单元格背景的方式。从图片中可以看出,它缺少一些区域:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:@"Cell"] autorelease];
cell.backgroundColor = [UIColor greenColor];
}
// Configure the cell...
}
问题:我如何在 tableView 单元格的开头和结尾更改颜色?现在单元格在这些区域中是透明的,并从整个 tableView 下方显示 self.view.backgroundColor。这些区域确实是透明的,因为在滚动 tableView 时,纹理背景保持在同一位置。
【问题讨论】:
-
嗨,请不要批准such a too minor suggested edit。将在您回复后删除评论:)
-
任何提高可读性的编辑都是我很乐意批准的。检查了情况,将再次批准。很抱歉,可读性和简单性对我来说很重要......顺便说一句,这个问题有什么提示吗? :)
标签: iphone uitableview