Search code examples
iosswiftuisearchcontrolleruistatusbar

How to make status bar transparent when using UISearchController


I was creating my own custom UISearchBar and UISearchController, following this tutorial and I wanted to add my own background using searchBar.setBackgroundImage() but the problem is that the image doesn't span the status bar as well. So I get a white status bar that looks like this:

enter image description here

Anyone know how to fix this?


Solution

  • enter image description here

    your give link project implemented:

    first go to main.storyboard delete constraint of tableview top after set tableview y position = 0 and set top constraint of tableview.

    your search bar view height set in viewcontroller.swift file.