Arv*_*ind 5 objective-c uitableview ios
在UITableView索引栏中如何更改索引栏上所选索引的颜色
我使用这样的代码
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex: (NSInteger)index
{
int i = 0;
for (i = 0; i< [dataArray count]; i++)
{
NSString *letterString = [alphabetsArray objectAtIndex:i];
if ([letterString isEqualToString:title])
{
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:i] atScrollPosition:UITableViewScrollPositionTop animated:YES];
lblSelectedIndex.text = [alphabetsArray objectAtIndex:index];
break;
}
}
return i;
}
Run Code Online (Sandbox Code Playgroud)
它滚动表上选定的索引charecter但我需要更改所选charecter的颜色.请帮助.
事实上,苹果官方并没有可以做到这一点。如果你这样做,苹果可能会拒绝你的应用程序。如果您只想自定义,indexBar那么下面的库可能会帮助您(它不能自定义您当前想要的内容)。
您可以使用自定义库GDIIndexBar(iOS 6+),您可以对其进行自定义。
https://github.com/gdavis/GDIIndexBar
\n\n这是示例片段GDIIndexBar
GDIIndexBar *indexBar = [[GDIIndexBar alloc] initWithTableView:tableView];\nindexBar.delegate = self;\n[self.view addSubview:indexBar];\nRun Code Online (Sandbox Code Playgroud)\n\n您可以按照以下方式进行定制:
\n\n[[GDIIndexBar appearance] setTextColor:[UIColor redColor]];\n[[GDIIndexBar appearance] setTextShadowColor:[UIColor purpleColor]];\n[[GDIIndexBar appearance] setTextFont:[UIFont italicSystemFontOfSize:11.5];\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
585 次 |
| 最近记录: |