How to change color of letters of sectionIndexTitlesForTableView?

前端 未结 8 608
情深已故
情深已故 2021-01-11 13:12

I need to change the color of sectionIndexTitlesForTableView in iOS 5. I could not find any method in the APIs to do the task. Can anyone offer me some help?

The se

相关标签:
8条回答
  • 2021-01-11 13:39

    Unfortunately I think there is no documented way to customize your index.

    Try to take a look to these Q&A:

    sectioned tableview index selection highlighting

    How do I change the color of the side Alphabet in an indexed UITableView?

    0 讨论(0)
  • 2021-01-11 13:44

    Swift 2.0

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

    self.tblYourTableView.sectionIndexColor = UIColor.redColor()
    

    0 讨论(0)
  • 2021-01-11 13:48
    - (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
    
    }
    
    0 讨论(0)
  • 2021-01-11 13:48

    You can also change the section index colors by changing the tintColor of the tableView.

    tableView.tintColor = .red
    
    0 讨论(0)
  • 2021-01-11 13:50

    Write Bellow code in your viewDidLoad (for swift)

    tableName.sectionIndexColor = UIColor.lightGrayColor()

    0 讨论(0)
  • 2021-01-11 13:51

    Swift 3

    you can just set the:

    tableView.sectionIndexColor 
    

    to whatever color your want like:

    tableView.sectionIndexColor = .red
    
    0 讨论(0)
提交回复
热议问题