2

我一直在尝试创建一个具有清晰背景的分组 UItableView。但由于某种原因,这些部分仍然具有浅灰色。我试图将 backgroundview 设置为 nil,但它不起作用。我还尝试将 backgroundView 设置为具有 clearColor 的视图,但也没有用。不知道我在这里做错了什么。

// make table's background clear
[self.myTable setBackgroundView:nil];
[self.myTable setBackgroundView:[[[UIView alloc] init] autorelease]];

UIView *bgView = [[UIView alloc] initWithFrame:self.myTable.frame];
bgView.backgroundColor = [UIColor clearColor];
self.myTable.backgroundView = bgView;
[bgView release]; 
4

1 回答 1

1

如果您试图使单元格的背景清晰,您需要将 UICellView 的backgroundView属性更改为实际视图(nil 不起作用),在

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

添加这个

cell.backgroundView = [[[UIView alloc] init] autorelease];

这将为单元格创建一个空白/空背景视图

于 2012-09-13T18:06:25.967 回答