Swift-如何摆脱UISearchController中的深色背景?

时间:2019-04-24 02:31:32

标签: ios swift uisearchcontroller

我有这个黑暗的背景:

image of the problem

这是我的代码:

class SearchController: UIViewController, UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate {

    let searchController = UISearchController(searchResultsController: nil)

    override func viewDidLoad() {

        searchController.searchBar.delegate = self

        searchController.searchResultsUpdater = self as? UISearchResultsUpdating
        self.definesPresentationContext = true

        self.navigationItem.titleView = searchController.searchBar

        searchController.hidesNavigationBarDuringPresentation = false

        self.definesPresentationContext = true

    }

}

我该怎么办? 谢谢!

1 个答案:

答案 0 :(得分:2)

尝试添加

searchController.dimsBackgroundDuringPresentation = false

https://developer.apple.com/documentation/uikit/uisearchcontroller