Reputation: 7434
I've used UISearchController. When I click on the search bar, navigation bar hides and search bar goes to the top of the screen. But, it shows extra space between top of the screen and the search bar
How do I change statusBar color to default searchBar gray color ?
StatusBar font colour is white, hence when user click search bar, auto above status bar information becomes invisible.So i just need to cover that area by default gray color too, then user can see clearly the status bar.Like this
Upvotes: 5
Views: 2891
Reputation: 7434
Figured it out , just need to add this code to viewDidLoad :-
definesPresentationContext = true
Upvotes: 1
Reputation: 38162
You can try one of following based on your implementation:
If you are using storyboards Click on the view controller or TableView Controller which you have set up for your tableview and go to its attribute inspector and look under ViewController section and set the Extend Edges section to be under Top Bars.
If you are not using storyboards set the settings using the viewcontrollers edgesForExtendedLayout property and that should do the trick.
Upvotes: 1
Reputation: 11773
The extra space is your status bar which you is lost in your white background.
func viewDidLoad() {
super.viewDidLoad()
edgesForExtendedLayout = UIRectEdge.None
}
Upvotes: 2