热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

HowtochangecoloroflettersofsectionIndexTitlesForTableView?

IneedtochangethecolorofsectionIndexTitlesForTableViewiniOS5.Icouldnotfindanymethodi

I need to change the color of sectionIndexTitlesForTableView in iOS 5. I could not find any method in the APIs to do the task. Can anyone offer me some help?

我需要在iOS 5中更改sectionIndexTitlesForTableView的颜色。我在API中找不到任何方法来完成任务。谁能给我一些帮助?

The sectionIndexTitlesForTableView means the vertical bar in right hand side to show the the titles for the sections.

sectionIndexTitlesForTableView表示右侧的垂直条,用于显示各部分的标题。

Thanks.

7 个解决方案

#1


1  

Unfortunately I think there is no documented way to customize your index.

不幸的是,我认为没有记录的方法来自定义您的索引。

Try to take a look to these Q&A:

试着看看这些问答:

sectioned tableview index selection highlighting

分段tableview索引选择突出显示

How do I change the color of the side Alphabet in an indexed UITableView?

如何在索引的UITableView中更改侧面Alphabet的颜色?

#2


23  

Go to the IB and change the text COLOR to white, Works for meenter image description here

转到IB并将文本颜色更改为白色,适合我

//=========================================

And in Swift, you can also change Programatically by:

在Swift中,您还可以通过以下方式更改:

self.my_tableView.sectiOnIndexColor= UIColor.greenColor()

#3


11  

Following code is a straight solution. api is available from iOS 6

以下代码是直接的解决方案。 api可从iOS 6获得

 [tableView setSectionIndexColor:[UIColor greenColor]];

#4


3  

Swift 2.0

The code line below will change the font color of the section index on table view. I have attached the resulting screenshot of the implementation.

下面的代码行将更改表视图上节索引的字体颜色。我附上了实现的结果屏幕截图。

self.tblYourTableView.sectiOnIndexColor= UIColor.redColor()

enter image description here

#5


2  

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


    for(UIView *view in [tableView subviews])
    {
        if([[[view class] description] isEqualToString:@"UITableViewIndex"])
        {
        [view performSelector:@selector(setIndexColor:) withObject:[UIColor redColor]];
        }
    }



    static NSString *MyIdentifier = @"MyIdentifier";

//***Table cell create

}

#6


2  

Write Bellow code in your viewDidLoad (for swift)

在viewDidLoad中编写Bellow代码(用于swift)

tableName.sectiOnIndexColor= UIColor.lightGrayColor()

tableName.sectiOnIndexColor= UIColor.lightGrayColor()

#7


1  

Swift 3

you can just set the:

你可以设置:

tableView.sectionIndexColor 

to whatever color your want like:

你想要的任何颜色:

tableView.sectiOnIndexColor= .red

推荐阅读
author-avatar
你就夜沉思
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有