ios 8中的UISearchBar未在UIStatusBar下扩展其背景色

ios 8中的UISearchBar未在UIStatusBar下扩展其背景色,ios,objective-c,ios8,uisearchbar,uisearchcontroller,Ios,Objective C,Ios8,Uisearchbar,Uisearchcontroller,我有一个UIViewController,里面有一个UICollectionView,上面有一个UISearchBar。问题是,当我点击我的搜索栏,它隐藏了导航栏,搜索栏的背景色没有延伸到状态栏下 下面是我如何设置UISearchBar和UISearchController的: UINavigationController *searchResultsController = [[self storyboard] instantiateViewControllerWithIdentifier:[

我有一个UIViewController,里面有一个UICollectionView,上面有一个UISearchBar。问题是,当我点击我的搜索栏,它隐藏了导航栏,搜索栏的背景色没有延伸到状态栏下

下面是我如何设置UISearchBar和UISearchController的:

UINavigationController *searchResultsController = [[self storyboard] instantiateViewControllerWithIdentifier:[ADC_SEARCH_RESULTS_CONTROLLER_IDENT copy]];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 44.0);
[self.view insertSubview:self.searchController.searchBar belowSubview:self.navigationController.navigationBar];
self.definesPresentationContext = YES;
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;
SuggestionResultsTVC *vc = (SuggestionResultsTVC *)searchResultsController.topViewController;
vc.tableView.contentInset = UIEdgeInsetsMake(0.0f, 0.f, 0.f, 0.f);
self.searchController.searchBar.clipsToBounds = YES;
以下是关闭搜索栏时UIViewController的屏幕截图:

以下是搜索栏处于活动状态时视图控制器的屏幕截图:

在故事板或xib文件中,转到属性检查器->模拟度量,并将状态栏从“推断”更改为“无”


我在simulator中构建应用程序,并激活UISearchBar,然后在xcode中输入“查看UI层次结构”选项,您可以在下面的屏幕中找到它:


我很清楚,灰色背景颜色来自我的UIViewController下的UIDimmingView->解决方案是更改我的UIViewController的UIView的颜色,这在UIDimmingView的上方,与颜色匹配的UISearchBar背景相匹配。

在我看来,您的UISearchBar可能会在点击后向其父级的UINavigationController发送调用。因此,请尝试修补以下问题:

self.navigationController.view.backgroundColor = [UIColor blackColor]; 
self.navigationController.navigationBar.translucent = NO;

我不想隐藏状态栏,我只想使背景颜色,或它下面的对象的颜色与搜索栏的颜色相同。不管怎样,我试过了,但没用。