既可以在初始化的时候设置,也可以在代理方法中设置,有改变数据的颜色,和改变背景的颜色
1,在初始化的时候直接设置如下 _tableView.sectionIndexColor = [UIColor greenColor];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, W,H - 64) style: UITableViewStyleGrouped];
_tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.sectionIndexColor = [UIColor greenColor];//索引字体背景颜色
_tableView.sectionIndexBackgroundColor = [UIColor redColor];//索引整体背景颜色
_tableView.sectionIndexTrackingBackgroundColor = [UIColor blueColor];//索引点击时的背景颜色
2,是在代理方法中设置
//section右侧index数组
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
tableView.sectionIndexColor =[UIColor redColor];//索引字体颜色
tableView.sectionIndexBackgroundColor = [UIColor grayColor];//索引背景颜色
tableView.sectionIndexTrackingBackgroundColor = [UIColor blueColor];//点击后的背景颜色
return _array;
}