HpT*_*erm 73
编辑/关注iOS7(2013年9月)阅读Graham Perks的答案,了解iOS7的后续行动,并向他解释sectionIndexTrackingBackgroundColor和sectionIndexBackgroundColor
为未来的读者跟进(2012年9月)这个问题.
从iOS 6开始,现在可以更改索引颜色文本和背景.有两个功能可用(参见iOS 6文档).
sectionIndexColor
用于表视图索引文本的颜色.
@property(nonatomic, retain) UIColor *sectionIndexColor
Run Code Online (Sandbox Code Playgroud)
表视图可以在视图的侧面显示索引,使用户可以更轻松地快速导航表的内容.此属性指定用于此区域中显示的文本的颜色.
可用性:适用于iOS 6.0及更高版本.
声明于:UITableView.h
sectionIndexTrackingBackgroundColor
用于表视图的索引背景区域的颜色.
@property(nonatomic, retain) UIColor *sectionIndexTrackingBackgroundColor
Run Code Online (Sandbox Code Playgroud)
表视图可以在视图的侧面显示索引,使用户可以更轻松地快速导航表的内容.此属性指定当用户拖动手指时在索引背景中显示的颜色.
可用性:适用于iOS 6.0及更高版本.
声明于:UITableView.h
Gra*_*rks 13
在iOS 7中,要更改正常的背景颜色,请使用该sectionIndexBackgroundColor属性.
sectionIndexTrackingBackgroundColor是用手指跟踪时的背景颜色.
(感谢HpTerm提供了适用于iOS 6的初始指针.)
小智 9
在你的viewDidLoad(快速)中添加以下代码:
tableView.sectionIndexColor = UIColor.lightGrayColor()
Run Code Online (Sandbox Code Playgroud)
更改索引部分背景颜色和文本颜色的优化方法
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
// Background color
view.tintColor = [UIColor whiteColor];//[UIColor colorWithRed:77.0/255.0 green:162.0/255.0 blue:217.0/255.0 alpha:1.0];
// Text Color
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"tableSection"]]];
}
Run Code Online (Sandbox Code Playgroud)

我想我刚才读错了问题。
如果您的意思是让您导航表视图的部分标题的 AZ 索引,那么它无法更改,目前不可能。或者您也可以创建自己的。
跟进
这只适用于iOS6之前。iOS6及以上版本请参考HpTerm的回答。
| 归档时间: |
|
| 查看次数: |
17909 次 |
| 最近记录: |