gpt4 book ai didi

iphone - UITableView "bounce area"中的浅灰色背景

转载 作者:行者123 更新时间:2023-12-03 18:10:45 46 4
gpt4 key购买 nike

Apple 的 iPhone 应用程序(例如 Music 和 Contants)使用 UITableView 中的搜索栏。当您向下滚动以使搜索栏向下移动时, ScrollView 内容上方的空白区域具有浅灰色背景颜色(请参见屏幕截图)。

Screenshot of Contacts app showing light gray background

(请注意,搜索栏顶部有一条稍暗的边缘线。默认的 UISearchBar 不存在这种情况,但子类化应该注意这一点。)

我尝试设置 UITableView 的背景颜色,但这也会影响行。有谁知道如何达到这个效果?我是否必须重写实现drawRect:或者是否有内置方法?

最佳答案

设置透明度不利于性能。您想要的是搜索栏上方的灰色区域,但在列表末尾之外它仍然应该是白色的。

您可以将 subview 添加到位于内容上方的 UITableView 中。

CGRect frame = self.list.bounds;
frame.origin.y = -frame.size.height;
UIView* grayView = [[UIView alloc] initWithFrame:frame];
grayView.backgroundColor = [UIColor grayColor];
[self.listView addSubview:grayView];
[grayView release];

如果您愿意,您可以向 View 添加更多奇特的东西,也许是淡入淡出,或者分隔线,而无需子类化 UISearchBar

关于iphone - UITableView "bounce area"中的浅灰色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1166236/

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