Swift - 如何摆脱UISearchController中的这个黑暗背景?

问题描述 投票:2回答:1

我有这个黑暗的背景:

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

    }

}

我该怎么办?谢谢!

ios swift uisearchcontroller
1个回答
2
投票

尝试添加此功能

searchController.dimsBackgroundDuringPresentation = false

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

© www.soinside.com 2019 - 2024. All rights reserved.