搜索控制器.dimsBackgroundDuringPresentation还会使状态栏变暗吗?

时间:2018-07-13 09:24:53

标签: swift uisearchcontroller uistatusbar

我具有设置搜索控制器的功能,该功能已添加到“查看并加载”中。

func setUpSearchController() {
        searchController.delegate = self
        searchController = UISearchController(searchResultsController: nil)
        searchController.hidesNavigationBarDuringPresentation = true
        searchController.dimsBackgroundDuringPresentation = true
        searchController.searchBar.sizeToFit()
        searchController.searchBar.backgroundColor = .white
        searchController.searchBar.barTintColor = .white
        searchController.searchBar.placeholder = "Search"
        searchController.searchBar.searchBarStyle = .minimal
        searchController.searchBar.tintColor = Colours.brandGreen
        definesPresentationContext = true
        messagesTableView.tableHeaderView = searchController.searchBar
    }

在搜索栏上单击时,搜索控制器会按预期的方式将背景变暗

searchController.dimsBackgroundDuringPresentation = true

问题在于它还会使状态栏变暗,使UI看起来很丑陋。有谁知道如何将状态栏也变暗?

一如既往,任何帮助将不胜感激。下图。 Status Bar Illustration

更新

我意识到我正在使用TableView标头中的搜索控制器搜索栏,并将其更改为

messagesTableView.tableHeaderView = searchController.searchBar

navigationItem.searchController = searchController

我得到了预期的结果。但是,我仍然希望在“表格视图”标题内使用搜索控制器搜索栏。

0 个答案:

没有答案
相关问题