UITableView背景色iOS 9

时间:2015-08-09 11:50:50

标签: ios objective-c xcode uitableview ios9

我有一个UITableView,我想将其背景颜色设置为透明。表视图的背景颜色和界面构建器的所有子视图都设置为透明。它适用于iOS 8& 7.但是,不是iOS 9.任何想法?

cellForRowAtIndexPath方法:

[cell setSelectedBackgroundView:[[UIView alloc] init]];
[cell.selectedBackgroundView setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundColor:[UIColor clearColor]];
[cell.contentView setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView setBackgroundColor:[UIColor clearColor]];

2 个答案:

答案 0 :(得分:10)

<强>目标C:

[self.yourTableView setBackgroundColor:[UIColor clearColor]];

<强>夫特:

self.yourTableView.backgroundColor = .clear

XCode 7.0错误。没有从故事板中获取

答案 1 :(得分:-1)

即使在代码中创建UITableView并将其设置为我的UIViewController的私有属性,也会发生这种情况。但是,如果UITableView是全局变量,则不会发生此问题。

我怀疑Apple正在我的UIViewController上使用ivars,将UITableView的背景颜色设置为UIColor whiteColor而不问我。我已经检查过了,并且要在UITableView上调用setBackgroundColor。

相关问题