代码之家  ›  专栏  ›  技术社区  ›  Ortwin Gentz

如何为UITableView的节索引设置着色颜色?

  •  9
  • Ortwin Gentz  · 技术社区  · 14 年前

    4 回复  |  直到 11 年前
        1
  •  13
  •   Ortwin Gentz    11 年前

    从ios6.0开始,实际上可以自定义节索引的色调。相关属性为: sectionIndexColor sectionIndexTrackingBackgroundColor .

    sectionIndexBackgroundColor 被触摸。

        2
  •  4
  •   Kevin Delord    11 年前

    可能有点晚了,但我必须处理iOS7的这个问题,我可能会帮助你。

    iOS 7中有一个新方法,名为:

    @property(nonatomic, retain) UIColor *sectionIndexColor
    

    现在您可以设置不被触摸时用于表视图节索引背景的颜色。

    self.friendsTableView.sectionIndexTrackingBackgroundColor = [UIColor aColor]; // background color while the index view is being touched
    if ([self.friendsTableView respondsToSelector:@selector(sectionIndexBackgroundColor)])
        self.friendsTableView.sectionIndexBackgroundColor = [UIColor aColor]; // background color while the index view is NOT touched at all
    
        3
  •  2
  •   Robert Atkins    10 年前

    appearance proxy 要设置这些:

    [UITableView appearance].sectionIndexColor = [UIColor myTintColor];

        4
  •  1
  •   Alex Milde    14 年前

    简而言之: 更多是不可能的。