我的 UINavigationItem 的 titleView 中有一个 UISearchBar 与 UISearchController 关联。当我向后导航时,它似乎在闪烁。有人以前见过这个吗?
闪光视频 https://www.youtube.com/watch?v=1-0TdqGNROg
@interface HNTileSearchViewController () <HNTileSearchResultsProtocol, SWRevealViewControllerDelegate, UISearchBarDelegate, HNSetSearchFiltersProtocol, HNKeywordResultsProtocol>
...
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) UISearchBar * searchBarTop;
...
@end
@implementation HNTileSearchViewController
...
- (void) customPreSetup {
HNKeywordResultsTableViewController * searchResultsController = [self.storyboard instantiateViewControllerWithIdentifier:HNKeywordResultsTableViewControllerStoryboardIdentifier];
searchResultsController.delegate = self;
_searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
_searchController.searchResultsUpdater = searchResultsController;
_searchController.hidesNavigationBarDuringPresentation = NO;
_searchController.dimsBackgroundDuringPresentation = NO;
_searchBarTop = _searchController.searchBar;
_searchBarTop.delegate = self;
_searchBarTop.placeholder = NSLocalizedString(@"Search heynay", nil);
_searchBarTop.showsCancelButton = NO;
_searchBarTop.showsScopeBar = NO;
self.navigationItem.titleView = _searchBarTop;
self.definesPresentationContext = YES;
}
- (void) viewDidLoad {
[super viewDidLoad];
[self customPreSetup];
...
}
....
@end
我遇到了同样的问题,我用两种方法解决了:
首先,您可以将 searchStyle 设置为 Prominent:
searchController.searchBar.searchBarStyle = .Prominent
顺便说一句,我是用 Swift 写的,这个解决方案的问题是搜索图标和文本以及占位符的颜色较深,如果背景颜色较深,看起来会很糟糕。
我找到的第二个解决方案是这样的:
navigationController!.navigationBar.translucent=false
navigationController!.navigationBar.barTintColor=UIColor.redColor()
searchController.searchBar.barTintColor=UIColor.redColor()
searchController.searchBar.searchBarStyle = .Prominent
searchController.searchBar.translucent=false
关键是导航栏和搜索栏都不是半透明的,并且两者具有相同的颜色。
我希望这可以帮助你
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)