How to change the color of the letters of an indexTitlesForTableView section?

I need to change the color of the IndexTitlesForTableView section in iOS 5. I could not find any method in the API to complete the task. Can anybody help me?

SectionIndexTitlesForTableView means a vertical bar on the right side to display headings for sections.

Thank.

+8
ios iphone ipad
Jan 23 2018-12-12T00:
source share
8 answers

Unfortunately, I think there is no documentary way to tune the index.

Try a look at these Q&A:

highlighted selection of tableview partition indexes

How to change side alphabet color in indexed UITableView?

+1
Jan 23 '12 at 13:22
source share

Go to IB and change the COLOR text to white, Works for me enter image description here

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

And in Swift, you can also change Programatically:

self.my_tableView.sectionIndexColor = UIColor.greenColor() 
+23
Nov 29 '13 at 6:35
source share

The following code is a direct solution. api available from iOS 6

  [tableView setSectionIndexColor:[UIColor greenColor]]; 
+11
Jun 12 '15 at 12:46 on
source share

Swift 2.0

The line of code below will change the font color of the section index in the table view. I attached the resulting screenshot of the implementation.

 self.tblYourTableView.sectionIndexColor = UIColor.redColor() 

enter image description here

+3
May 15 '16 at
source share
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { for(UIView *view in [tableView subviews]) { if([[[view class] description] isEqualToString:@"UITableViewIndex"]) { [view performSelector:@selector(setIndexColor:) withObject:[UIColor redColor]]; } } static NSString *MyIdentifier = @"MyIdentifier"; //***Table cell create } 
+2
Apr 30 '13 at 5:30
source share

Enter the Bellow code in your DidLoad view (for quick)

tableName.sectionIndexColor = UIColor.lightGrayColor ()

+2
Feb 12 '16 at 12:05
source share

Swift 3

you can simply install:

 tableView.sectionIndexColor 

for any color you want:

 tableView.sectionIndexColor = .red 
+2
Jul 19 '17 at 19:53 on
source share

Since no one has added this yet, you can also change the colors of the section index by changing the tintColor tableView.

 tableView.tintColor = .red 
0
Jul 07 '19 at 21:23
source share



All Articles