gpt4 book ai didi

ios - 导航栏中的灰色背景,在推送期间将 searchController 添加到导航项

转载 作者:行者123 更新时间:2023-12-01 15:47:04 25 4
gpt4 key购买 nike

我在导航 Controller 中有一个表 View ,以便我可以将详细 View Controller 推送到堆栈上。它工作正常,直到我向导航项添加搜索 Controller ,如下所示:

searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.tintColor = Colors.mlLabel
navigationItem.searchController = searchController
definesPresentationContext = true

它导致临时灰色背景,见下文:

enter image description here

调试 View 层次结构时,看起来像 UIViewControllerWrapperView's _UIParallaxDimmingView (在下面选择)导致这种情况,因为导航栏和状态栏都是透明的。

enter image description here

我怎样才能解决这个问题?

注:设置 animated房产在 pushViewController()false有效,但我想保留动画。

更新:这似乎仅在 iOS 13 上有问题。甚至可能是最近的某个版本,因为我之前没有遇到过这个问题。

更新 2:我现在在我的应用程序中的多个地方都注意到了同样的问题,而且不仅仅是与 SearchController 结合使用。 .基本上是 _UIParallaxDimmingView伸出 Nose 。

最佳答案

更新

这是我用来从大标题到小标题的代码。这些是大标题 View Controller 的属性,或者更具体地说是它的导航 Controller :

navigationController.navigationBar.prefersLargeTitles = true
navigationController.topViewController?.extendedLayoutIncludesOpaqueBars = true

也许上面的第二行可能对你有帮助?

至于推送任何 View Controller ,我看到我已经覆盖了导航 Controller 的推送功能(因为我对标签栏中的每个选项卡都使用了导航 Controller ):
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
if viewControllers.count >= 1 {
viewController.hidesBottomBarWhenPushed = true
viewController.navigationItem.largeTitleDisplayMode = .never
}
super.pushViewController(viewController, animated: animated)
}

上一个答案

我以前在我的生活中看到过几次,它总是必须对 View Controller 本身的背景颜色做一些事情。如果它是透明的,你会在动画时看到这些东西。

但由于它是一个搜索 Controller ,它可能是导航栏。无论如何,由于问题仅从 iOS13 开始,我相信可以使用以下方法解决问题:
searchController.searchBar.backgroundColor = UIColor.clear (or whatever color)

这个新属性 (UISearchBar.searchTextField.backgroundColor) 自 iOS13 以来已添加,所以也许这会为您解决问题? :)

关于ios - 导航栏中的灰色背景,在推送期间将 searchController 添加到导航项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58854175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com