0
votes

I am having a view controller with a UITableView and a Custom View.The storyboard configuration is Custom View is alligned with top, leading and trailing margin of my view controller's main view.Custom View is having a constant height. UITableView's top is alligned with bottom of the Custom View. UITableView's leading, trailing and bottom is alligned with leading, trailing and bottom of main view. I am adding a UISearchController's search bar as UITableView header. This view controller is pushed on UINavigationController Stack. Now when user clicks on search bar navigation bar hides to make way for searchbar.But as custom view is above the UITableView it accomodates the position where UISearchBar should have been. I want to move Custom View out also and take the UISearchBar position which would have been in normal scenario without Custom View above. Help will be appreciated.Initial Configuration

After search bar is clicked

1

1 Answers

0
votes

Set the the IBOutlet for the Custom View's Height constraint and when user clicks on search bar then set e.g "customview.heightConstraint.constant = 0" in search bar delegate method

func searchBarTextDidBeginEditing(_ searchBar: UISearchBar){
customview.heightConstraint.constant = 0
}