我想在UISearchDisplayController的表视图背景中添加自定义UIImageView,并将表视图的背景颜色设置为clearColor.尝试了一些不同的方法,但找不到合适的解决方案.知道如何处理这个问题吗?
注意:我不想添加到searchDisplayController的searchResultsTableView的视图层次结构中,而是覆盖它下面的另一个兄弟视图)
AJ.*_*AJ. 25
您可以使用与主表类似的方式设置背景图像,只在searchDisplayControllerDidBeginSearch委托方法中设置它.例如:-
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
[controller.searchResultsTableView setDelegate:self];
UIImageView *anImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gradientBackground.png"]];
controller.searchResultsTableView.backgroundView = anImage;
[anImage release];
controller.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
controller.searchResultsTableView.backgroundColor = [UIColor clearColor]; }
Run Code Online (Sandbox Code Playgroud)