导航项中的Search Controller显示黑条

时间:2019-05-22 06:06:32

标签: ios swift uinavigationbar uisearchcontroller

您好,我使用

设置了搜索控制器
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]

现在,当我点击搜索栏时,会出现大的底部黑条

该如何解决?

查看调试

enter image description here

enter image description here

2 个答案:

答案 0 :(得分:0)

删除此

$ ./bin/number_evens_odds
enter the amount of numbers: 10
enter number  1: 21
enter number  2: 22
enter number  3: 23
enter number  4: 24
enter number  5: 119
enter number  6: 121
enter number  7: 131
enter number  8: 140
enter number  9: 141
enter number 10: 143

 numbers
--------
      21
      22
      23
      24
     119
     121
     131
     140
     141
     143

   evens
--------
      22
      24
     140

    odds
--------
      21
      23
     119
     121
     131
     141
     143

numbers      even      odd
-------- -------- --------
      21       22       21
      22       24       23
      23      140      119
      24               121
     119               131
     121               141
     131               143
     140
     141
     143

答案 1 :(得分:0)

好的,我可以解决此问题。我正在分享此信息,因此这可能对其他面临相同问题的人有所帮助。

解决此问题。在视图中将出现我将self.extendedLayoutIncludesOpaqueBars设置为true的方法

 override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.extendedLayoutIncludesOpaqueBars = true

    }

希望对某人有帮助:)

此处输出

enter image description here

相关问题