gpt4 book ai didi

objective-c - UITableView 索引栏自定义

转载 作者:太空狗 更新时间:2023-10-30 03:42:06 26 4
gpt4 key购买 nike

我会称我的技能几乎是“基础”的,我理解我阅读和看到的大部分关于 Objective-C 的内容,但这有点超出我的理解范围。

我有一个带有透明背景和透明单元格的 tableView,不幸的是,我正在为其开发应用程序的人坚持让背景显示为主要是灰色的。我的问题是右边的索引栏。我读过文本颜色、背景颜色等在自定义方面是不受限制的。是否有人创建了自己的索引栏并将其附加到 tableView 的滚动方法?

就像我说的,我不知道从哪里开始。我所需要的只是我相信在正确方向上的一点。我需要创建一个小的 UIView 并处理触摸事件吗?

最佳答案

就这样吧:

if ([[self tableView] respondsToSelector:@selector(setSectionIndexColor:)])
{
// In iOS 6 there is a own method available to set the index color
[[self tableView] setSectionIndexColor:[UIColor whiteColor]];
}
else
{
// Use this hack in previous iOS releases
for(UIView *view in [self.tableView subviews])
{
if([view respondsToSelector:@selector(setIndexColor:)])
{
[view performSelector:@selector(setIndexColor:) withObject:[UIColor whiteColor]];
}
}
}

关于objective-c - UITableView 索引栏自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5139668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com