【问题标题】:UITableView background color iOS 9UITableView 背景颜色 iOS 9
【发布时间】:2015-11-01 10:39:09
【问题描述】:

我有一个 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]];

【问题讨论】:

  • 首先,这不是一个好主意,因为滚动性能会受到影响。除此之外,我认为这是一个错误。归档雷达。
  • 必须尝试cell.contentView.backgroundColor 吗?在报告之前尝试再挖掘一点..嗯..我也认为这是一个错误。

标签: ios objective-c xcode uitableview ios9


【解决方案1】:

目标-c:

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

斯威夫特:

self.yourTableView.backgroundColor = .clear

XCode 7.0 错误。没有从情节提要中提取

【讨论】:

  • 是的,我之前就知道了。
  • 这个错误在 beta 5 中是否仍然存在?你试过了吗?
  • 抱歉,我没有尝试 beta 5。
  • @hasan83 是的,这仍然是 beta 5 中的一个错误
  • 我有类似的约束问题 - 对于某些屏幕,它们只是消失了。
【解决方案2】:

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

我怀疑 Apple 正在围绕我的 UIViewController 上的 ivars,将 UITableView 的背景颜色设置为 UIColor whiteColor 而没有询问我。我已经检查过了,调用通过 UITableView 上的 setBackgroundColor 进行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-07
    • 2023-03-03
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-12
    相关资源
    最近更新 更多