【问题标题】:How to color the area of a tableviewcell behind the index bar?如何为索引栏后面的 tableviewcell 区域着色?
【发布时间】:2011-03-10 05:45:29
【问题描述】:

在我的一个应用程序中,我为 tableviewcells 使用交替颜色。表格视图具有一个索引栏,可以快速滚动。

但是现在我的单元格被“切断”了——索引栏后面的区域没有着色,尽管标题在索引字母后面可见。所以我认为这不是索引栏不透明的问题,而是更多的 tableviewcells 太短或类似的问题。

这是它现在的样子:

显然,绿色 tableviewcells 应该到达索引栏下方并填补空白。 我尝试通过设置单元格内容视图和背景视图的背景颜色来为表格视图单元着色。 textlabel 和 accessoryview 都将 clearcolor 设置为它们的背景颜色(并且不是不透明的)。

任何帮助将不胜感激!

编辑:

分隔符设置为白色,这就是它们在索引栏后面不可见的原因。如果我将它们设置为另一种颜色,它们就像标题一样在索引栏后面可见。

【问题讨论】:

    标签: iphone objective-c cocoa-touch ios uitableview


    【解决方案1】:

    我通常这样做:

    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height)];
    bgView.backgroundColor = [UIColor greenColor];
    cell.backgroundView = bgView;
    [bgView release];
    

    据我所知,仅设置 cell.backgroundView.backgroundColor 是行不通的...

    -迈克尔

    【讨论】:

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