替代文字 http://img210.imageshack.us/img210/5992/searchdisplaycontroller.png
以下对象是否可自定义?
1. UISearchBar 范围按钮(UISegmentedController)
2. UIResultsTableView
3.键盘(至少它是黑色的)
替代文字 http://img210.imageshack.us/img210/5992/searchdisplaycontroller.png
以下对象是否可自定义?
1. UISearchBar 范围按钮(UISegmentedController)
2. UIResultsTableView
3.键盘(至少它是黑色的)
替代文字 http://img527.imageshack.us/img527/9775/searchdisplaycontrollerz.png
我能够通过一种 hack 代码更改分段控件:
- (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;
}
}
}}
然而按钮是巨大的,我怎样才能修复它,让它们和原来的一样漂亮?
我可以使用以下代码自定义表格视图:
- (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]; }
但是,当您触摸取消按钮时,界面会在返回原始 tableview 之前闪烁白色。如何解决这个问题?
尽管尝试了每个分段控制样式,但我也永远无法让按钮变小。这是我需要用来至少在 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;
}
}
}
}
}