I\'ve got a UITableView in which I set its header to be a search bar.
tableView.tableHeaderView = searchController.searchBar
Everything wor
Try this:
if (@available(iOS 11, *)){
[searchVC.searchBar addObserver:self forKeyPath:@"frame" options: NSKeyValueObservingOptionNew context:nil];
}else{
[view addSubview:searchVC.searchBar];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
CGRect rect = [change[@"new"] CGRectValue];
if (rect.origin.y == 14) {
CGRect temp = rect;
temp.origin.y = 20;
[self.searchVC.searchBar setValue:@(temp) forKey:@"frame"];
}else if (rect.size.height == 56){
CGRect temp = rect;
temp.size.height = 50;
[self.searchVC.searchBar setValue:@(temp) forKey:@"frame"];
}
}