调整UISearchDisplayController灰色黑色覆盖
任何人都知道如何调整调暗的黑色过度,一旦你点击search栏?
我有问题,当我点击取消桌面将花费然后animation消失。
我用这个调整我的结果tableview。
-(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView { tableView.frame =fTableView.frame;//CGRectMake(26, 100, 280, 310); //fTableView.frame; tableView.backgroundColor = [UIColor colorWithRed:243.0/255.0 green:236.0/255.0 blue:212.0/255.0 alpha:1]; }
当点击search栏时,灰色覆盖层已满,而不是我定义的大小。
当点击取消button时,视图将消耗。
我结合了几个答案,以移动暗淡的覆盖帧。
1:覆盖UISearchDisplayController类
@interface MySearchController : UISearchDisplayController
2:覆盖setActive函数
- (void)setActive:(BOOL)visible animated:(BOOL)animated { [super setActive: visible animated: animated]; //move the dimming part down for (UIView *subview in self.searchContentsController.view.subviews) { //NSLog(@"%@", NSStringFromClass([subview class])); if ([subview isKindOfClass:NSClassFromString(@"UISearchDisplayControllerContainerView")]) { CGRect frame = subview.frame; frame.origin.y += 10; subview.frame = frame; } } }
3:将xib / storyboardsearch显示控制器从UISearchDisplayController更改为MySearchController
我以为searchDisplayController拥有一个单独的tableview,所以我的猜测是你需要调整一个。
一些东西: <yourSearchViewController>.view.frame =self.tableView.frame;
或者如果你没有它作为类variables,在一个方法接收它作为参数,例如:
-(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView { controller.view.frame = self.tableView.frame; tableView.backgroundColor = [UIColor colorWithRed:243.0/255.0 green:236.0/255.0 blue:212.0/255.0 alpha:1]; }
另外,你可能想要inheritance它并在本地覆盖它的视图属性。
希望这可以帮助!
UISearchDisplayController
确实拥有自己的tableview,这不容易驯服。 我遇到了这样的事情,我仍然在寻找更好的解决scheme。
-(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { [controller.searchResultsTableView setDelegate:self]; CGFloat gr = 12.0; controller.searchResultsTableView.backgroundColor = [UIColor colorWithRed:gr green:gr blue:gr alpha:0.0]; [controller.searchResultsTableView setSeparatorStyle:UITableViewCellSelectionStyleNone]; CGRect searchTableFrame = CGRectMake(7, 105, 305, 292); [controller.searchResultsTableView setFrame:searchTableFrame]; }
上面的代码确实将背景设置为透明,但似乎默默地忽略了框架的大小。
编辑:解决我在这里find了强大的解决scheme。 这救了我的命。