1 // Set Search Button Title to Done
2 for (UIView *searchBarSubview in [self.searchBar subviews]) {
3 if ([searchBarSubview conformsToProtocol:@protocol(UITextInputTraits)]) {
4 // Before iOS 7.0
5 @try {
6 [(UITextField *)searchBarSubview setReturnKeyType:UIReturnKeyDone];
7 //[(UITextField *)searchBarSubview setKeyboardAppearance:UIKeyboardAppearanceAlert];
8 }
9 @catch (NSException * e) {
10 // ignore exception
11 }
12 } else {
13 // iOS 7.0
14 for(UIView *subSubView in [searchBarSubview subviews]) {
15 if([subSubView conformsToProtocol:@protocol(UITextInputTraits)]) {
16 @try {
17 [(UITextField *)subSubView setReturnKeyType:UIReturnKeyDone];
18 //[(UITextField *)searchBarSubview setKeyboardAppearance:UIKeyboardAppearanceAlert];
19 }
20 @catch (NSException * e) {
21 // ignore exception
22 }
23 }
24 }
25 }
26 }