【问题标题】:iOS – Grouped UITableView with tiled background displayed incorrectiOS – 平铺背景的分组 UITableView 显示不正确
【发布时间】:2012-07-27 15:08:13
【问题描述】:

我正在尝试在UITableView 上使用平铺背景,方法是:tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"gradient_squares.png"]];

但它不会正确显示,因为每个部分都会显示与UITableView 背景重叠的背景图块。

我尝试将UITableViewCell 的背景颜色设置为清除颜色无济于事。

编辑:添加屏幕截图和图块

【问题讨论】:

  • 尝试自定义表格单元格并根据您的要求绘制此图像...
  • 为什么要自定义 UITableViewCell?我想为 UITableView 设置平铺背景。 UITableViewCells 应该“悬停”在平铺背景上并且没有背景(清晰)。
  • 您希望背景随表格滚动还是保持静止?
  • 我希望它保持静止。但是,看看它在使用表格滚动时的外观也会很有趣。

标签: ios uitableview background-image


【解决方案1】:

这篇文章对我有用:https://stackoverflow.com/a/5480535/294661

在 UIViewController 中设置每个视图的 backgroundColor 属性。

【讨论】:

    【解决方案2】:

    如果您有全尺寸背景图片(不是图案图片),以下代码可以解决您的问题。

    [[self tableView] setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background_image.png"]]];
    

    【讨论】:

      猜你喜欢
      • 2014-01-08
      • 1970-01-01
      • 1970-01-01
      • 2011-01-27
      • 1970-01-01
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-07
      相关资源
      最近更新 更多