UITableView 背景色 iOS 9
UITableView background color iOS 9
我有一个 UITableView,我想将其背景颜色设置为透明。 table 视图和界面生成器中所有子视图的背景颜色设置为透明。它适用于 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]];
Objective-c:
[self.yourTableView setBackgroundColor:[UIColor clearColor]];
Swift:
self.yourTableView.backgroundColor = .clear
XCode 7.0 错误。未从情节提要
即使在代码中创建 UITableView 并将其设置为我的 UIViewController 的私有 属性 时,我也会遇到这种情况。但是,如果UITableView是一个全局变量,就不会出现这个问题。
我怀疑 Apple 在我的 UIViewController 上绕过 ivars,在没有询问我的情况下将 UITableView 的背景颜色设置为 UIColor whiteColor。我已经检查过,调用通过 UITableView 上的 setBackgroundColor 完成。
我有一个 UITableView,我想将其背景颜色设置为透明。 table 视图和界面生成器中所有子视图的背景颜色设置为透明。它适用于 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]];
Objective-c:
[self.yourTableView setBackgroundColor:[UIColor clearColor]];
Swift:
self.yourTableView.backgroundColor = .clear
XCode 7.0 错误。未从情节提要
即使在代码中创建 UITableView 并将其设置为我的 UIViewController 的私有 属性 时,我也会遇到这种情况。但是,如果UITableView是一个全局变量,就不会出现这个问题。
我怀疑 Apple 在我的 UIViewController 上绕过 ivars,在没有询问我的情况下将 UITableView 的背景颜色设置为 UIColor whiteColor。我已经检查过,调用通过 UITableView 上的 setBackgroundColor 完成。