gpt4 book ai didi

objective-c - UITableView 不要 float 部分标题

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:52:17 26 4
gpt4 key购买 nike

是否可以不 float 具有样式 UITableViewStylePlainUITableView 的节标题?

我正在 build AcaniChat, an open-source version of iPhone's native Messages app ,我想制作时间戳部分标题,但它们不应 float 。

我知道对于样式为 UITableViewStyleGrouped 的 TableView ,部分标题不会 float ,但该样式看起来不太像我想要的。我是否应该只使用该样式并重新设置表格 View 的样式以使其看起来像我想要的那样?

如果我能弄清楚如何制作 https://stackoverflow.com/questions/6564712/nsfetchedresultscontroller-nsdate-section-headers,我可能会这样做.

最佳答案

UITableViewStyleGrouped 的有趣之处在于 tableView 将样式添加到 cells 而不是 TableView。

样式作为 backgroundView 添加到单元格中,作为一个名为 UIGroupTableViewCellBackground 的类,它根据单元格在该部分中的位置处理绘制不同的背景。

所以一个非常简单的解决方案是使用 UITableViewStyleGrouped,将表格的 backgroundColor 设置为 clearColor,并简单地替换 cellForRow 中单元格的 backgroundView:

cell.backgroundView = [[[UIView alloc] initWithFrame:cell.bounds] autorelease];

关于objective-c - UITableView 不要 float 部分标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6563757/

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