如何在索引的UITableView中更改侧面Alphabet的颜色? [英] How do I change the color of the side Alphabet in an indexed UITableView?

查看:61
本文介绍了如何在索引的UITableView中更改侧面Alphabet的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有字母索引的表格视图,并使用侧面字母表快速浏览列表。对于那些不熟悉的人,使用它:

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:

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {

我的问题是我的应用程序刚剥了皮黑。所以现在很难看到旁边的字母。

My problem is that my application has just been skinned black. And so now it's hard to see the alphabet letters on the side.

我无法弄清楚如何改变字母表的颜色。如果可能的话,我希望它是'白色'。

I can't figure out how to change the color of the alphabet. I'd like it to be 'white' if at all possible.

推荐答案

据我所知,不幸的是不可能要自定义索引中显示的文本的颜色,我能够最接近的是能够修改背景颜色和索引的字体。

From what I can tell unfortunately it is not possible to customize the color of the text displayed in the index, the closest I've been able to come is being able to modify the background color and the font of the index.

Erica Sadun的iPhone开发者手册中有一些代码,展示了如何访问UITableViewIndex视图(一个未记录的类)。如果有的话,可以在本书的第175页找到对它的引用。这样可以访问背景颜色和字体。您可以在此处查看与此课程相关的非官方文档。

There is some code in the iPhone Developers cookbook by Erica Sadun which shows how to access the UITableViewIndex view (an undocumented class). You can find the reference to it on page 175 of the book if you have it. Which gives access to the background color and the font. You can see an unofficial document related to this class here.

警告这是未记录的未使用的类的使用,因此您需要谨慎使用它。

WARNING This is undocumented use of an undocumented class so you need to be cautious about using it.

这是一个来自cookbook的代码片段进行了少量修改:

Here is a code snippet from the cookbook with minor modifications:

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {    

  for(UIView *view in [tv subviews])
  {
    if([[[view class] description] isEqualToString:@"UITableViewIndex"])
    {

      [view setBackgroundColor:[UIColor whiteColor]];
      [view setFont:[UIFont systemFontOfSize:14]];
    }
  }

  //rest of cellForRow handling...

} 

这说明了如何访问和UITableViewIndex视图并在某些方面进行修改。看起来该视图没有任何子视图,所以它可能会使用索引标题数组进行一些自定义绘制。

This illustrates how you can access and the UITableViewIndex view and modify it in some aspects. It looks like the view doesn't have any subviews so it is likely doing some custom drawing with the array of index titles.

它不完美但希望它有点帮助。

It's not perfect but hopefully it helps a little.

保罗

这篇关于如何在索引的UITableView中更改侧面Alphabet的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆