如何更改sectionIndexTitlesForTableView字母的颜色?

use*_*015 11 iphone ipad ios

我需要在iOS 5中更改sectionIndexTitlesForTableView的颜色.我在API中找不到任何方法来执行任务.谁能给我一些帮助?

sectionIndexTitlesForTableView表示右侧的垂直条,用于显示各部分的标题.

谢谢.

Jas*_*eet 24

转到IB并将文本颜色更改为白色,适合我在此输入图像描述

// =========================================

在Swift中,您还可以通过以下方式更改:

self.my_tableView.sectionIndexColor = UIColor.greenColor()
Run Code Online (Sandbox Code Playgroud)


Raj*_*esh 11

以下代码是直接的解决方案.api可从iOS 6获得

 [tableView setSectionIndexColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)


ric*_*cks 5

斯威夫特 3

你可以设置:

tableView.sectionIndexColor 
Run Code Online (Sandbox Code Playgroud)

任何你想要的颜色:

tableView.sectionIndexColor = .red
Run Code Online (Sandbox Code Playgroud)


Bep*_*ppe 1

不幸的是,我认为没有记录的方法来自定义索引。

尝试看看这些问答:

分区表视图索引选择突出显示

如何更改索引 UITableView 中侧面字母的颜色?