如何为UITableView右侧sectionIndex设置字体大小?

时间:2016-01-11 07:02:47

标签: ios uitableview fonts

如何设置UITableView右侧sectionIndex?

的字体大小

right sectionIndex

1 个答案:

答案 0 :(得分:1)

Try this solution, this will definitely help you ->

Step 1) Add this method in your class

- (void)setUITableViewSectionIndexFontSize:(UITableView*)tableView{
    //UI the index view
    for(UIView *view in [tableView subviews]) {
        if([view respondsToSelector:@selector(setIndexColor:)]) {
            [view performSelector:@selector(setIndexColor:) withObject:[UIColor grayColor]];

            if ([view respondsToSelector:@selector(setFont:)]) {
                [view performSelector:@selector(setFont:) withObject:[UIFont systemFontOfSize:20.0]];
                [view performSelector:@selector(setBackgroundColor:) withObject:[UIColor blueColor]];

            }
        }
    }
}

Step 2) Now add this line just before [tableView reloadData] line ->

[self setUITableViewSectionIndexFontSize:tableView];
[tableView reloadData];