ios - UISearchController:昏暗的覆盖层覆盖了搜索栏本身

标签 ios swift uisearchbar uisearchcontroller

我在针对 iOS 10+ 的项目中使用 UISearchController,对于 iOS 11,我可以将其设置为 navigationItem.searchController,但对于 iOS 10,我必须手动添加搜索栏。

在 iOS 10 上存在一个问题,当 obscuresBackgroundDuringPresentation 设置为 true 时,当搜索栏成为第一响应者时会出现一个暗淡的叠加层,但它不仅覆盖搜索结果区域,还有搜索栏本身。

在 iOS 11 上完美运行。

有什么我必须设置/更改的吗?

谢谢!

最佳答案

definesPresentationContext设置为true

例如

    navigationItem.searchController = searchController
    definesPresentationContext = true

关于ios - UISearchController:昏暗的覆盖层覆盖了搜索栏本身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51720371/

相关文章:

ios - 来自类 'UIViewController' 和 'UISearchBar' 的多重继承

iphone - 如何用动画隐藏/显示 UISearchBar 范围栏?

ios - Restkit 自定义映射

ios - swift/IOS : Accessing objects that are stored inside NSSet

ios - Apple LLVM 编译器 4.2 错误退出代码 1

ios - 尝试选择尚未添加的注释

ios - 如何在 Swift 中使用#selector 操作传递参数?

ios - CoreLocation 类的 Codable 扩展

ios - 快速将 backButton 从默认 UINavigationbar 移动到 customNavigationbar

swift - 当搜索栏为空或为零时表为空