问题描述
我想在UISearchDisplayController的表视图背景中添加自定义UIImageView,并将表视图的背景颜色设置为clearColor。尝试了一些不同的方法,但找不到合适的解决方案。知道怎么处理这个吗?
I want to add a custom UIImageView to UISearchDisplayController's table view background and set table view's background color to clearColor. Tried a few different approach but couldn't find the right solution. Any idea how to approach this?
注意:我不想添加到searchDisplayController的searchResultsTableView的视图层次结构中,而是覆盖它下面的另一个兄弟视图)
Note: I don't want to add to searchDisplayController's searchResultsTableView's view hierarchy, but rather overlay another sibling view below it)
推荐答案
您可以使用与主表类似的方式设置背景图像,只在searchDisplayControllerDidBeginSearch委托方法中设置它。例如: -
You can set the background image in a similar way you would for your main table, only set it in the searchDisplayControllerDidBeginSearch delegate method. For instance:-
- (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]; }
这篇关于如何向UISearchDisplayController的表视图添加自定义背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!