您好,我已经使用设置搜索 Controller
private func setupSearchbar() {
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Contacts"
self.navigationItem.searchController = searchController
self.definesPresentationContext = true
}
在我添加此代码之前一切都工作正常
UINavigationBar.appearance().isOpaque = true
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = UIColor(named: "PrimaryDark")
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.font:Constants.AppTheme.Fonts.font(type: .FONT_BOLD, size: 22) ,NSAttributedString.Key.foregroundColor:UIColor.white]
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.font:Constants.AppTheme.Fonts.font(type: .FONT_BOLD, size: 34) ,NSAttributedString.Key.foregroundColor:UIColor.white]
现在,当我点击搜索栏时,会出现大底黑条
如何解决这个问题?
查看调试
最佳答案
好的,我可以解决这个问题。我分享此内容可能会对面临相同问题的其他人有所帮助。
解决这个问题。在 View 中将出现我已将 self.extendedLayoutIncludesOpaqueBars
设置为 true
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.extendedLayoutIncludesOpaqueBars = true
}
希望对某人有帮助:)
这里是输出
关于ios - 导航项中的搜索 Controller 显示黑条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56250292/