我需要在iOS 5中更改sectionIndexTitlesForTableView的顏色。我無法在API中找到任何方法來執行此任務。任何人都可以給我一些幫助嗎?如何更改sectionIndexTitlesForTableView的字母顏色?
sectionIndexTitlesForTableView表示右側的垂直條,用於顯示節的標題。
謝謝。
我需要在iOS 5中更改sectionIndexTitlesForTableView的顏色。我無法在API中找到任何方法來執行此任務。任何人都可以給我一些幫助嗎?如何更改sectionIndexTitlesForTableView的字母顏色?
sectionIndexTitlesForTableView表示右側的垂直條,用於顯示節的標題。
謝謝。
不幸的是,我認爲沒有文檔記錄的方式來定製您的索引。
嘗試看看到這些問與答&答:
sectioned tableview index selection highlighting
How do I change the color of the side Alphabet in an indexed UITableView?
致Downvoter - >你是否意識到這是2012年問的?那現在我們有不同的工具?好... – Beppe
- (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
}
這似乎有點...哈克... – CW0007007
你可以參考這個: http://stackoverflow.com/a/30803486/1517506 – Parthpatel1105
轉到IB和更改文本顏色爲白色,工作對我來說
// =========================================
而且在斯威夫特,你還可以通過編程方式改變:
self.my_tableView.sectionIndexColor = UIColor.greenColor()
下面的代碼是直的解決方案。 API可從iOS 6的
[tableView setSectionIndexColor:[UIColor greenColor]];
寫婁代碼在viewDidLoad中(對於SWIFT)
tableName.sectionIndexColor = UIColor.lightGrayColor()
斯威夫特3
你可以設置:
tableView.sectionIndexColor
到任何顏色你想要一個像:
tableView.sectionIndexColor = .red
爲什麼我的問題投下來了? – user403015