gpt4 book ai didi

ios - 类似于 UISearchBar 的自定义 UITableView header

转载 作者:行者123 更新时间:2023-11-29 10:41:28 26 4
gpt4 key购买 nike

我想将我的自定义标题 View 放入 UITableView,并使用 UISearchBar 具有的自动滚动偏移调整。

我该怎么做?

最佳答案

找到解决方法。我将标题作为 subview 添加到 UISerachBar 并隐藏搜索栏的所有其他 subview

-(void)addHeaderView:(UIView *)view
{
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:view.frame];
[searchBar layoutSubviews];

UIView *searchBarView = searchBar.subviews[0];

for (UIView *subview in searchBarView.subviews)
subview.hidden = YES;

view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[searchBarView addSubview:view];
self.tableHeaderView = searchBar;
}

关于ios - 类似于 UISearchBar 的自定义 UITableView header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24366650/

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