Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of UITable view indexbar selected index

In UITableView index bar how to change color of selected index on index bar

I use code like this

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:   (NSInteger)index
{
    int i = 0;
    for (i = 0; i< [dataArray count]; i++)
    {
        NSString *letterString = [alphabetsArray objectAtIndex:i];
        if ([letterString isEqualToString:title])
        {
            [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:i] atScrollPosition:UITableViewScrollPositionTop animated:YES];
            lblSelectedIndex.text = [alphabetsArray objectAtIndex:index];

           break;
        }
    }
    return i;
}

it scroll table on that selected index charecter but i need to change color of that selected charecter.Please help.

like image 916
Arvind Avatar asked Nov 01 '22 05:11

Arvind


1 Answers

Actually there is not official Apple available to do that. And Apple may reject you app if you do that. If you just wants to customize indexBar then below library may help you (It can't customize what you currently wants).

You can use custom library GDIIndexBar (iOS 6+), which you can customize.

https://github.com/gdavis/GDIIndexBar

Here's sample snippet for GDIIndexBar

GDIIndexBar *indexBar = [[GDIIndexBar alloc] initWithTableView:tableView];
indexBar.delegate = self;
[self.view addSubview:indexBar];

You can customize as per follows:

[[GDIIndexBar appearance] setTextColor:[UIColor redColor]];
[[GDIIndexBar appearance] setTextShadowColor:[UIColor purpleColor]];
[[GDIIndexBar appearance] setTextFont:[UIFont italicSystemFontOfSize:11.5];
like image 133
Akshit Zaveri Avatar answered Nov 15 '22 05:11

Akshit Zaveri