【问题标题】:iPad groupTableViewBackgroundColor broken?iPad groupTableViewBackgroundColor 坏了?
【发布时间】:2011-02-23 09:02:08
【问题描述】:

有人知道如何在 iPad 上获取 groupTableViewBackgroundColor 吗?这似乎在 4.2 中被打破了。我尝试使用颜色选择器从视图中获取 if,但是当我将其重新用作另一个视图的背景颜色时,它是不同的灰色阴影。

【问题讨论】:

    标签: cocoa-touch ipad ios uikit


    【解决方案1】:

    好的,原来如此

    [UIColor groupTableViewBackgroundColor]
    

    在 iPad 上的行为与在 iPhone 上的行为不同。分组的表格视图实际上有一个渐变作为背景。我找到了两种可能的解决方案来满足我的特殊需求,它们是:

    1. 在背景上添加我需要的任何内容到表格视图本身(如果需要,给它一个内容插入)
    2. 设置我自己的背景颜色,纯色或其他

    【讨论】:

      【解决方案2】:

      为 UITableView(在 iPhone 和 iPad 上)设置背景的最佳方法是创建一个 UIView,设置它的 backgroundColor 属性并将其设置为 UITableView 的 backgroundView。

      UIView *backgroundView = [[UIView alloc] initWithFrame:frame];
      backgroundView.backgroundColor = [UIColor redColor];
      self.tableView.backgroundView = backgroundView;
      

      如果您想使用图像作为背景,请创建 UIImageView 并将其添加为 UIView 的子视图。

      编辑:对不起,我误解了你的问题。

      【讨论】:

      • 遇到了这个答案,它确实对我有帮助 +1
      猜你喜欢
      • 2011-06-18
      • 1970-01-01
      • 2012-09-23
      • 1970-01-01
      • 2019-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多