【问题标题】:iOS 11 SearchDisplayController shows black status bariOS 11 UISearchDisplayController 显示黑色状态栏
【发布时间】:2017-09-30 20:51:24
【问题描述】:
我知道 SearchDisplayController 已被弃用,但 Storyboard 仍然支持它,并且它是一种在视图控制器之上呈现 tableViewController 的简单方法。我一直在使用它,我仍然更喜欢使用它。在 iOS 11 中,当我运行我的应用程序时,SearchDisplayController 的状态栏。搜索栏聚焦后,是黑色的。有谁知道如何解决这个错误?此外,如果您意识到,搜索者的边缘是关闭的。我正在使用默认的 iOS 11 搜索栏。下面附上截图:
【问题讨论】:
标签:
ios
ios11
searchdisplaycontroller
【解决方案1】:
您是否尝试将 extendedLayoutIncludesOpaqueBars 属性设置为 true?
searchDisplayController.extendedLayoutIncludesOpaqueBars = true
【解决方案2】:
这实际上不是最好的解决方案,但它可以改变状态栏的颜色。
if let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView {
statusBar.backgroundColor = //YOUR COLOR HERE
}
请记住,这将影响整个应用程序。如果您只需要更改某些视图,则保存以前的颜色以恢复它。
问候。