【问题标题】:Continue alternating row colors in the "bounce area" of a UITableView在 UITableView 的“反弹区域”中继续交替行颜色
【发布时间】:2012-01-07 17:16:26
【问题描述】:

在 iPhone 上的 Weather.app 中,滚动越过 Hourly tableview 的边界会继续显示交替的表格单元格,只是其中没有任何文本(见下图)。我想知道如何复制这种外观。 This question 提供了一种解决方案,但我希望有一种更有效的方法,然后在我的表格视图上方添加空白单元格的图像。

谢谢

【问题讨论】:

    标签: iphone uitableview uikit


    【解决方案1】:

    您可以使用 UITableView 的 headerViewfooterView 属性。这些允许您指定将放置在内容单元之前和之后的自定义 UIView。

    因此,您应该使用一些具有交替颜色的虚拟内部视图来初始化 UIView。这个 UIView 的高度应该等于tableView.frame.size.height。然后就这样做:

    
    tableView.headerView = headerViewWithFakeColors;
    tableView.footerView = footerViewWithFakeColors;
    

    此外,您还需要更改 contentInset 属性,以便这些虚假的页眉和页脚视图仅在用户弹跳时可见(使用 contentInset 您可以控制表格视图开始弹跳的点)

    
    tableView.contentInset = UIEdgeInsetsMake(headerViewWithFakeColors.frame.size.height, 0, -footerViewWithFakeColors.frame.size.height, 0);
    

    【讨论】:

      猜你喜欢
      • 2010-11-13
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多