alt text http://img210.imageshack.us/img210/5992/searchdisplaycontroller.png
以下对象是否可自定义?
1。 UISearchBar范围按钮(UISegmentedController)
2。 UIResultsTableView
第3。键盘(至少它是黑色的)
答案 0 :(得分:3)
alt text http://img527.imageshack.us/img527/9775/searchdisplaycontrollerz.png
我能够通过一种黑客代码更改分段控件:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
for (UIView *subview in self.view.subviews) {
for (UIView *subview2 in subview.subviews) {
if ([subview2 isKindOfClass:[UISegmentedControl class]]) {
UISegmentedControl *segmentedControl = (UISegmentedControl *)subview2;
segmentedControl.tintColor = [UIColor blackColor];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
}
}
}}
然而按钮是巨大的,我怎么能修复它,所以它们和原版一样漂亮?
答案 1 :(得分:1)
我可以使用以下代码自定义tableview:
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView {
tableView.backgroundColor = [UIColor colorWithRed:(19.0 / 255.0) green:(19.0 / 255.0) blue:(19.0 / 255.0) alpha:1.0];
tableView.separatorColor = [UIColor blackColor]; }
但是,当您触摸取消按钮时,界面将闪烁白色,然后返回原始桌面视图。如何解决这个问题?
答案 2 :(得分:1)
尽管尝试了每个segmentedControlStyle,我也无法让按钮变小。这是我需要使用的代码,以至少在IOS4上获得正确的色调:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
static BOOL tintAlreadyChanged = NO;
if (tintAlreadyChanged) return;
NSLog(@"Searching subViews for UISegmentControl:");
//fix segmented control
for (UIView *subview in self.view.subviews) {
//NSLog(@"\n\nsubView = %@",subview);
for (UIView *subview2 in subview.subviews) {
//NSLog(@"subView2 = %@",subview2);
for (UIView *subview3 in subview2.subviews) {
//NSLog(@"subView3 = %@",subview3);
if ([subview3 isKindOfClass:[UISegmentedControl class]]) {
NSLog(@"Found UISegment SubView = %@",subview3);
UISegmentedControl *segmentedControl = (UISegmentedControl *)subview3;
segmentedControl.tintColor = [UIColor blackColor];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBezeled;
tintAlreadyChanged = YES;
}
}
}
}
}