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

标签 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

    }

}

我该怎么办? 谢谢!

最佳答案

尝试添加这个

searchController.dimsBackgroundDuringPresentation = false

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

关于ios - Swift - 如何摆脱 UISearchController 中的深色背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55821564/

相关文章:

ios - html 5 input DateTime-Local 任何浏览器 ios 9 native 日期时间选择器 - 如何选择年份?

ios - Swift- 将图像宽度设置为等于外部图像的宽度

ios - 在 UINavigationBar 上呈现 UISearchController 时推送 View Controller

uitableview - UISearchController 隐藏搜索栏上方的结果

ios - 在 iOS 中编辑键盘布局

iphone - 应用程序在调试版本中运行良好,但在发布版本中崩溃,可能是什么原因?

ios - xcode 快速约束问题与 tableview 和 uilabel 休息

ios - UIImagePickerController 模式关闭后 UITabBar 消失

ios - 在 UINavigationController 中使用带有 UITabBarController 的 UISearchController 时,搜索栏被截断

ios - 使用 UICollectionView 和 UICollectionViewCells 创建刷卡堆栈?