2

Hi I have setup search controller using

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

    }

Everything was working fine until I add this code

    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]

Now When I tap on search bar big bottom black bar appears

How to fix this ?

View Debugging

enter image description here

enter image description here

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98

2 Answers2

2

Okay So I am able to fix this issue. I am sharing this so this might helpful to other facing the same issue.

to fix this issue. In view will appear method I have set self.extendedLayoutIncludesOpaqueBars to true

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

    }

Hope it helps to someone :)

Here is output

enter image description here

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98
0

Remove this

UINavigationBar.appearance().isOpaque = true

UINavigationBar.appearance().isTranslucent = false
steveSarsawa
  • 1,559
  • 2
  • 14
  • 31