gpt4 book ai didi

objective-c - 如果填充了 UISearchBar,则更改 UITableView setBackgroundColor

转载 作者:行者123 更新时间:2023-12-01 19:23:13 26 4
gpt4 key购买 nike

如果有人能帮我解决这个问题,那就太好了。预先感谢最大

如果在 UISearchBar 中输入文本,我想将 UITableView setBackgroundColor 从 clearColor 更改为 whiteColor 。

即占位符文本消失。

立即删除文本时,即重新出现占位符文本

UITableView setBackgroundColor 恢复为 clearColor。

    CGRect frame = CGRectMake(0, 140, 320, 170);

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(13, 100, 300, 40)];
[searchBar setDelegate:self];
[searchBar setPlaceholder:@"Species/Common Name"];
[searchBar setShowsCancelButton:YES];
[searchBar setTintColor:kITBarTint];
[self.view addSubview:searchBar];

self.tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
[self.tableView setBackgroundColor:[UIColor clearColor]];
[self.tableView setDataSource:self];
[self.tableView setDelegate:self];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.view addSubview:self.tableView];
[self.tableView setTableHeaderView:header];

最佳答案

使用搜索栏委托(delegate):

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor grayColor];
}

关于objective-c - 如果填充了 UISearchBar,则更改 UITableView setBackgroundColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9160027/

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