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

后端 未结 12 955
温柔的废话
温柔的废话 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:32

    Here's the best solution I've found to adjust the background colour of the index bar on the side. It works in iOS7 and probably iOS6.

    Add this to your viewDidLoad

    if ([_tableView respondsToSelector:@selector(setSectionIndexColor:)]) {
        _tableView.sectionIndexBackgroundColor = [UIColor clearColor];
        _tableView.sectionIndexTrackingBackgroundColor = [UIColor whiteColor];
    }
    

    The first one is the default colour, the second is the background colour when you are scrolling.

提交回复
热议问题