【问题标题】:Swift - How to get rid of this dark background in UISearchController?Swift - 如何摆脱 UISearchController 中的这种深色背景?
【发布时间】:2019-04-24 02:31:32
【问题描述】:

我得到了这个黑暗的背景:

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】:

    尝试添加这个

    searchController.dimsBackgroundDuringPresentation = false
    

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

    【讨论】:

    • @VictorLi 给了你声誉
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-15
    • 1970-01-01
    • 2015-11-01
    • 2020-11-18
    相关资源
    最近更新 更多