如何使用UISearchController设置导航栏背景颜色?

时间:2019-11-03 14:40:51

标签: ios swift xcode xcode11 swift4.2

如何保持导航栏背景颜色固定(例如黑色)?

问题:我的导航栏与UISearchViewController集成在一起。当我滚动以拉出SearchView时,整个导航栏将变得透明。有人可以告诉我为什么会这样,我注意到这种行为始于Xcode11构建。与我在Xcode 10上尝试过的一样,没有这种行为。

这是我的代码

    let searchController = UISearchController(searchResultsController: nil)
    searchController.obscuresBackgroundDuringPresentation = false
    searchController.hidesNavigationBarDuringPresentation = false

    navigationController?.navigationBar.prefersLargeTitles = false
    navigationItem.largeTitleDisplayMode = .never
    navigationItem.searchController = searchController
    navigationItem.hidesSearchBarWhenScrolling = true

0 个答案:

没有答案