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

后端 未结 12 960
温柔的废话
温柔的废话 2020-11-27 14:03

I have a table view with an alphabetical index and am using the side alphabet to get through the list quickly. For those not familiar, that uses this:

- (NS         


        
12条回答
  •  没有蜡笔的小新
    2020-11-27 14:27

    I was having the same problem and just found out a way of doing this, though this is using undocumented classes and methods so think one extra time before trying to upload it to the App Store. I should say that i've only tried this with iOS5 so I don't know if it will work for previous versions.

    I borrowed and modified the Erica Saunders cookbook example so that it now changes the text color to red:

    - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {    
    
      for(UIView *view in [tv subviews])
      {
        if([[[view class] description] isEqualToString:@"UITableViewIndex"])
        {
          [view performSelector:@selector(setIndexColor:) withObject:[UIColor redColor]];
        }
      }
    
      //rest of cellForRow handling...
    
    }
    

提交回复
热议问题