How to change background color of statusBar when search is active?

I used the UISearchController. When I click on the search bar, the navigation bar hides and the search bar jumps to the top of the screen. But it shows extra space between the top of the screen and the search bar

enter image description here

How to change default statusBar color to default gray color?

enter image description here

The color of the StatusBar font is white, so when the user clicks the search bar, auto above the status information becomes invisible. Therefore, I just need to cover this area with gray color by default, then the user can clearly see the status bar. Like this

enter image description here

+4
source share
3 answers

, viewDidLoad: -

definesPresentationContext = true
+1

- , .

func viewDidLoad() {
    super.viewDidLoad()
    edgesForExtendedLayout = UIRectEdge.None
}
+2

:

TableView Controller, , ViewController Extend Edges .

, , edgeCodeReference viewcontrollers, .

+1

Source: https://habr.com/ru/post/1609562/


All Articles