【发布时间】:2011-02-19 03:00:59
【问题描述】:
有没有办法自定义 UITableView 的字母部分索引的灰色?
【问题讨论】:
标签: ios iphone cocoa-touch uitableview colors
有没有办法自定义 UITableView 的字母部分索引的灰色?
【问题讨论】:
标签: ios iphone cocoa-touch uitableview colors
从 iOS 6.0 开始,实际上可以自定义节索引的色调颜色。相关属性为:sectionIndexColor 和 sectionIndexTrackingBackgroundColor。
iOS 7 添加了sectionIndexBackgroundColor,它指定了不被触摸时节索引的背景颜色。
【讨论】:
可能有点晚了,但由于我必须使用 iOS 7 处理这个问题,所以我可能会帮助你。
从 iOS 7 开始,有一个新方法叫做:
@property(nonatomic, retain) UIColor *sectionIndexColor
现在您可以设置在不被触摸时用于表格视图的节索引背景的颜色。
作为适用于 iOS 6 和 7 的正确代码,您可以:
self.friendsTableView.sectionIndexTrackingBackgroundColor = [UIColor aColor]; // background color while the index view is being touched
if ([self.friendsTableView respondsToSelector:@selector(sectionIndexBackgroundColor)])
self.friendsTableView.sectionIndexBackgroundColor = [UIColor aColor]; // background color while the index view is NOT touched at all
【讨论】:
您可能应该使用 UITableView 的 appearance proxy 来设置这些:
[UITableView appearance].sectionIndexColor = [UIColor myTintColor];
【讨论】:
简而言之: 您可以更改字体大小和完整的背景(不是圆形的) 更多是不可能的。
【讨论】: