添加子视图时以灰色背景色显示



我在左边有一个表格视图(它是一个iPad应用程序),在右边有一个空的子视图,当用户触摸单元格时会填充。这就是我选择的方式...看来:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SecondViewController *remedyScreen = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];       
    [self.rightPanel addSubview:remedyScreen.view];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

我的问题是这个 SecondViewController 总是以灰色背景显示,并且在 xib 上设置为清除清除,并且未选中 Opaque 属性。我假设这种奇怪的灰色背景颜色来自刚刚创建的子视图,因为即使我为 self.rightPanel 添加颜色,当我向其添加子视图时,它也会被灰色覆盖。我已经在代码设置中完成了设置clearColor和Opaque = NO,但我得到了相同的灰色背景。我在那里错过了什么?

试试这个:

UIView *backView = [[[UIView alloc] CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
backView.backgroundColor = [UIColor clearColor];
self.view.backgroundView = backView;

最新更新