tableview的联系人索引/修改索引的字体颜色

-(void)setupIndexTitle

{
    
    //将26个字母放进_indexTitles中,表示段名,也表示索引表的内容
    
    NSMutableArray *arrTmp=[NSMutableArray arrayWithCapacity:0];
    NSMutableArray *arr =[[NSMutableArray alloc]initWithObjects:@"当前城市", @"热门城市",nil];
    
    [arrTmp addObjectsFromArray:arr];
    for (char c='A';c<='Z';c++) {
        
        [arrTmp addObject:[NSString stringWithFormat:@"%c",c]];
        
    }
    
    if (indexTitles) {
        
        indexTitles=nil;
        
    }
    
    indexTitles = [[NSArray alloc]initWithArray:arrTmp];
    
}

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    
 
    return indexTitles;
    
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

//    return dataArr[section][@"group"];
}
-(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
    return index;
}


//修改索引颜色
tableView.sectionIndexBackgroundColor = [UIColor greenColor];//修改右边索引的背景色
tableView.sectionIndexColor = [UIColor orangeColor];//修改右边索引字体的颜色
tableView.sectionIndexTrackingBackgroundColor = [UIColor orangeColor];//修改右边索引点击时候的背景色


你可能感兴趣的:(tableview的联系人索引/修改索引的字体颜色)