使用 UISearchbar 和过滤后自定义新的 table

Customizing the new table after using UISearchbar and filtering

我正在使用 UISearchBar 来搜索我的 table。我的问题是,一旦我搜索某些内容,UISearchBar 就会创建一个新的 table 视图作为搜索结果的叠加层,而这个新的 table 基本上没有任何属性(没有背景,分隔符插入,一切白色等)。我如何自定义这个新的 table 视图(让它看起来像之前的视图)。我找不到任何可以访问它的函数来赋予它属性,例如背景颜色左右。

是否有可用于自定义视图的功能?我正在使用这个函数,至少单元格的高度是相同的:

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 90
}

以下屏幕截图最能说明我的问题。

更新tableView的背景视图如下,

tableView.backgroundColor = UIColor.red()

tableView.backgroundView = UIView()
tableView.backgroundView.backgroundColor = UIColor.red()

好吧,经过几个小时的尝试,找到了解决方案。以下两个功能还帮助我自定义了新 table 视图的单元格,该视图覆盖了我的旧视图。我不知道 willDisplay 函数,但它的工作原理应该是:

  override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 90
    }

    override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        if(searchActive){
            cell.backgroundColor = UIColor.clear
            tableView.backgroundView = UIImageView(image: UIImage(named: "darkBackground"))
            tableView.separatorStyle = .none
        }
    }