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

标签 ios objective-c ios8 uisearchbar uisearchcontroller

我有一个 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 的屏幕截图: http://s4.postimg.org/x0rncg5e5/Screen_Shot_2015_09_02_at_5_09_41_PM.png

下面是搜索栏处于事件状态时 View Controller 的屏幕截图: http://s4.postimg.org/tv71m8mrx/Screen_Shot_2015_09_02_at_5_10_04_PM.png

最佳答案

在您的 Storyboard或 xib 文件中,转到属性检查器 -> 模拟指标并将状态栏从“推断”更改为“无”。

enter image description here

关于ios - UISearchBar 未在 ios 8 的 UIStatusBar 下扩展其背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32355684/

相关文章:

iphone - 检查 C 枚举是否存在

core-data - 如何在 Swift Int64 中使用 Core Data Integer 64?

ios - 如何调用另一个 Storyboard作为弹出窗口?

colors - Xcode 6 搜索栏颜色清晰变为黑色?

ios - 收到通知后,我如何才能在应用程序图标点击时获取有效负载?

ios - Swift:只调用一个 TableView 方法

ios - 如何将 NSMutableDictionary 从一个 View Controller 传递到另一个 View Controller ?

ios - SKAction.waitForDuration 在 SpriteKit 中不起作用

ios - 将 NSMutableDictionary 从一个 View 传递到另一个 View

ios - swift ,parse.com : how to pass data from query