如果UISearchController進入編輯狀態(tài)后掸宛,距離狀態(tài)欄太近或者導航欄遮擋住20的解決辦法:
重寫下面的方法:
-(void)viewDidLayoutSubviews {
? ? if(self.searchController.active){
? ? ? ? self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, 10, self.searchController.searchBar.frame.size.width, 44.0);
? ? ? ? [UIView animateWithDuration:0.1 animations:^{
? ? ? ? ? ? [self.view layoutIfNeeded];
? ? ? ? ? ? [self.searchController.searchBar layoutIfNeeded];
? ? ? ? }];
? ? }
}